diff --git a/src/Kp2aBusinessLogic/IKp2aApp.cs b/src/Kp2aBusinessLogic/IKp2aApp.cs
index 60a4a46f..0c92c942 100644
--- a/src/Kp2aBusinessLogic/IKp2aApp.cs
+++ b/src/Kp2aBusinessLogic/IKp2aApp.cs
@@ -12,11 +12,23 @@ using keepass2android.Io;
namespace keepass2android
{
+ public interface ICertificateValidationHandler
+ {
+ ///
+ /// Handles a failed certificate validation. Returns true if the users wants to continue, false otherwise.
+ /// see http://msdn.microsoft.com/en-us/library/system.net.icertificatepolicy(v=vs.110).aspx
+ ///
+ //bool OnServerCertificateError(int certificateProblem);
+
+ RemoteCertificateValidationCallback CertificateValidationCallback { get; }
+
+ }
+
///
/// Interface through which Activities and the logic layer can access some app specific functionalities and Application static data
///
/// This also contains methods which are UI specific and should be replacable for testing.
- public interface IKp2aApp
+ public interface IKp2aApp: ICertificateValidationHandler
{
///
/// Locks the currently open database, quicklocking if available (unless false is passed for allowQuickUnlock)
@@ -92,14 +104,7 @@ namespace keepass2android
void TriggerReload(Context context);
- ///
- /// Handles a failed certificate validation. Returns true if the users wants to continue, false otherwise.
- /// see http://msdn.microsoft.com/en-us/library/system.net.icertificatepolicy(v=vs.110).aspx
- ///
- //bool OnServerCertificateError(int certificateProblem);
-
- RemoteCertificateValidationCallback CertificateValidationCallback { get; }
-
+
bool CheckForDuplicateUuids { get; }
}
}
\ No newline at end of file
diff --git a/src/Kp2aBusinessLogic/Io/NetFtpFileStorage.cs b/src/Kp2aBusinessLogic/Io/NetFtpFileStorage.cs
index 9dce6041..8296781c 100644
--- a/src/Kp2aBusinessLogic/Io/NetFtpFileStorage.cs
+++ b/src/Kp2aBusinessLogic/Io/NetFtpFileStorage.cs
@@ -106,13 +106,13 @@ namespace keepass2android.Io
}
}
- private readonly Context _context;
+ private readonly ICertificateValidationHandler _app;
public MemoryStream traceStream;
- public NetFtpFileStorage(Context context)
+ public NetFtpFileStorage(Context context, ICertificateValidationHandler app)
{
- _context = context;
+ _app = app;
traceStream = new MemoryStream();
FtpTrace.AddListener(new System.Diagnostics.TextWriterTraceListener(traceStream));
@@ -171,18 +171,15 @@ namespace keepass2android.Io
if (!uri.IsDefaultPort) //TODO test
client.Port = uri.Port;
- //TODO Validate
- //client.ValidateCertificate += app...
-
- // we don't need to be thread safe in a classic sense, but OpenRead and OpenWrite don't
- //perform the actual stream operation so we'd need to wrap the stream (or just enable this:)
-
+ client.ValidateCertificate += (control, args) =>
+ {
+ args.Accept = _app.CertificateValidationCallback(control, args.Certificate, args.Chain, args.PolicyErrors);
+ };
client.EncryptionMode = ConnectionSettings.FromIoc(ioc).EncryptionMode;
-
- client.Connect();
- return client;
+ client.Connect();
+ return client;
}
@@ -373,7 +370,7 @@ namespace keepass2android.Io
public void StartSelectFile(IFileStorageSetupInitiatorActivity activity, bool isForSave, int requestCode, string protocolId)
{
- throw new NotImplementedException();
+ activity.PerformManualFileSelect(isForSave, requestCode, "ftp");
}
public void PrepareFileUsage(IFileStorageSetupInitiatorActivity activity, IOConnectionInfo ioc, int requestCode,