diff --git a/src/KP2AKdbLibraryBinding/KP2AKdbLibraryBinding.csproj b/src/KP2AKdbLibraryBinding/KP2AKdbLibraryBinding.csproj index 3c41dfc6..4da19c3e 100644 --- a/src/KP2AKdbLibraryBinding/KP2AKdbLibraryBinding.csproj +++ b/src/KP2AKdbLibraryBinding/KP2AKdbLibraryBinding.csproj @@ -42,9 +42,8 @@ - - - + + diff --git a/src/KP2AKdbLibraryBinding/libs/mips/libfinal-key.so b/src/KP2AKdbLibraryBinding/libs/mips/libfinal-key.so deleted file mode 100644 index 1c4391b8..00000000 Binary files a/src/KP2AKdbLibraryBinding/libs/mips/libfinal-key.so and /dev/null differ diff --git a/src/KeePassLib2Android/KeePassLib2Android.csproj b/src/KeePassLib2Android/KeePassLib2Android.csproj index 275418c0..9ed5983f 100644 --- a/src/KeePassLib2Android/KeePassLib2Android.csproj +++ b/src/KeePassLib2Android/KeePassLib2Android.csproj @@ -20,7 +20,7 @@ full False bin\Debug - DEBUG;EXCLUDE_TWOFISH;EXCLUDE_KEYBOARD;EXCLUDE_FILECHOOSER;EXCLUDE_JAVAFILESTORAGE;EXCLUDE_KEYTRANSFORM + DEBUG;INCLUDE_TWOFISH;EXCLUDE_KEYBOARD;EXCLUDE_FILECHOOSER;INCLUDE_JAVAFILESTORAGE;INCLUDE_KEYTRANSFORM prompt 4 False diff --git a/src/KeePassLib2Android/Serialization/IOConnection.cs b/src/KeePassLib2Android/Serialization/IOConnection.cs index 8bcf452f..b3daaa2f 100644 --- a/src/KeePassLib2Android/Serialization/IOConnection.cs +++ b/src/KeePassLib2Android/Serialization/IOConnection.cs @@ -68,6 +68,8 @@ namespace KeePassLib.Serialization // get { return m_bSslCertsAcceptInvalid; } set { m_bSslCertsAcceptInvalid = value; } } + + public static RemoteCertificateValidationCallback CertificateValidationCallback { get; set; } #endif // Web request methods @@ -192,11 +194,10 @@ namespace KeePassLib.Serialization private static void PrepareWebAccess() { - if(m_bSslCertsAcceptInvalid) + /* ServicePointManager.ServerCertificateValidationCallback = - IOConnection.AcceptCertificate; - else - ServicePointManager.ServerCertificateValidationCallback = null; + IOConnection.AcceptCertificate;*/ + ServicePointManager.ServerCertificateValidationCallback = CertificateValidationCallback; } private static IOWebClient CreateWebClient(IOConnectionInfo ioc, bool digestAuth) @@ -361,29 +362,25 @@ namespace KeePassLib.Serialization public override void Close() { base.Close(); - try + RepeatWithDigestOnFail(ioc, req => { - uploadData(IOConnection.CreateWebClient(ioc, false)); - } catch (WebException ex) - { - if ((ex.Response is HttpWebResponse) && (((HttpWebResponse) ex.Response).StatusCode == HttpStatusCode.Unauthorized)) - uploadData(IOConnection.CreateWebClient(ioc, true)); - else - throw; - } + req.Headers.Add("Translate: f"); + + if (method != null) + req.Method = method; + var data = this.ToArray(); + + using (Stream s = req.GetRequestStream()) + { + s.Write(data, 0, data.Length); + req.GetResponse(); + s.Close(); + } + }); } - void uploadData(WebClient webClient) - { - if (method != null) - { - webClient.UploadData(destinationFilePath, method, this.ToArray()); - } else - { - webClient.UploadData(destinationFilePath, this.ToArray()); - } - } + } public static Stream OpenWrite(IOConnectionInfo ioc) diff --git a/src/Kp2aBusinessLogic/IKp2aApp.cs b/src/Kp2aBusinessLogic/IKp2aApp.cs index e8c63a19..ec726578 100644 --- a/src/Kp2aBusinessLogic/IKp2aApp.cs +++ b/src/Kp2aBusinessLogic/IKp2aApp.cs @@ -1,4 +1,6 @@ using System; +using System.Net.Security; +using System.Security.Cryptography.X509Certificates; using Android.App; using System.IO; using Android.Content; @@ -14,8 +16,8 @@ namespace keepass2android /// 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 + { /// /// Locks the currently open database, quicklocking if available (unless false is passed for allowQuickUnlock) /// @@ -24,51 +26,52 @@ namespace keepass2android /// /// Loads the specified data as the currently open database, as unlocked. /// - void LoadDatabase(IOConnectionInfo ioConnectionInfo, MemoryStream memoryStream, CompositeKey compKey, ProgressDialogStatusLogger statusLogger, IDatabaseLoader databaseLoader); + void LoadDatabase(IOConnectionInfo ioConnectionInfo, MemoryStream memoryStream, CompositeKey compKey, + ProgressDialogStatusLogger statusLogger, IDatabaseLoader databaseLoader); /// /// Returns the current database /// - Database GetDb(); + Database GetDb(); /// /// Tell the app that the file from ioc was opened with keyfile. /// - void StoreOpenedFileAsRecent(IOConnectionInfo ioc, string keyfile); + void StoreOpenedFileAsRecent(IOConnectionInfo ioc, string keyfile); /// /// Creates a new database and returns it /// - Database CreateNewDatabase(); + Database CreateNewDatabase(); /// /// Returns the user-displayable string identified by stringKey /// - string GetResourceString(UiStringKey stringKey); + string GetResourceString(UiStringKey stringKey); /// /// Returns the value from the preferences corresponding to key /// - bool GetBooleanPreference(PreferenceKey key); + bool GetBooleanPreference(PreferenceKey key); /// /// Asks the user the question "messageKey" with the options Yes/No/Cancel, calls the handler corresponding to the answer. /// - void AskYesNoCancel(UiStringKey titleKey, UiStringKey messageKey, - EventHandler yesHandler, - EventHandler noHandler, - EventHandler cancelHandler, - Context ctx); + void AskYesNoCancel(UiStringKey titleKey, UiStringKey messageKey, + EventHandler yesHandler, + EventHandler noHandler, + EventHandler cancelHandler, + Context ctx); /// /// Asks the user the question "messageKey" with the options Yes/No/Cancel, but the yes/no strings can be selected freely, calls the handler corresponding to the answer. /// void AskYesNoCancel(UiStringKey titleKey, UiStringKey messageKey, - UiStringKey yesString, UiStringKey noString, - EventHandler yesHandler, - EventHandler noHandler, - EventHandler cancelHandler, - Context ctx); + UiStringKey yesString, UiStringKey noString, + EventHandler yesHandler, + EventHandler noHandler, + EventHandler cancelHandler, + Context ctx); /// /// Returns a Handler object which can run tasks on the UI thread @@ -84,6 +87,8 @@ namespace keepass2android /// 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); - } + //bool OnServerCertificateError(int certificateProblem); + + RemoteCertificateValidationCallback CertificateValidationCallback { get; } + } } \ No newline at end of file diff --git a/src/Kp2aBusinessLogic/Io/BuiltInFileStorage.cs b/src/Kp2aBusinessLogic/Io/BuiltInFileStorage.cs index ce078dd0..df44549e 100644 --- a/src/Kp2aBusinessLogic/Io/BuiltInFileStorage.cs +++ b/src/Kp2aBusinessLogic/Io/BuiltInFileStorage.cs @@ -37,31 +37,13 @@ namespace keepass2android.Io private readonly IKp2aApp _app; - class CertificatePolicity: ICertificatePolicy - { - private readonly IKp2aApp _app; - - public CertificatePolicity(IKp2aApp app) - { - _app = app; - } - - public bool CheckValidationResult(ServicePoint srvPoint, System.Security.Cryptography.X509Certificates.X509Certificate certificate, WebRequest request, - int certificateProblem) - { - if (certificateProblem == 0) //ok - return true; - return _app.OnServerCertificateError(certificateProblem); - } - } - - public BuiltInFileStorage(IKp2aApp app) { _app = app; //use the obsolute CertificatePolicy because the ServerCertificateValidationCallback isn't called in Mono for Android (?) - ServicePointManager.CertificatePolicy = new CertificatePolicity(app); - + //ServicePointManager.CertificatePolicy = new CertificatePolicity(app); + IOConnection.CertificateValidationCallback = app.CertificateValidationCallback; + } public IEnumerable SupportedProtocols diff --git a/src/Kp2aBusinessLogic/Kp2aBusinessLogic.csproj b/src/Kp2aBusinessLogic/Kp2aBusinessLogic.csproj index 5ef6e781..8e4b49ad 100644 --- a/src/Kp2aBusinessLogic/Kp2aBusinessLogic.csproj +++ b/src/Kp2aBusinessLogic/Kp2aBusinessLogic.csproj @@ -20,7 +20,7 @@ full false bin\Debug\ - TRACE;DEBUG;EXCLUDE_TWOFISH;EXCLUDE_KEYBOARD;EXCLUDE_FILECHOOSER;EXCLUDE_JAVAFILESTORAGE;EXCLUDE_KEYTRANSFORM + TRACE;DEBUG;INCLUDE_TWOFISH;EXCLUDE_KEYBOARD;EXCLUDE_FILECHOOSER;INCLUDE_JAVAFILESTORAGE;INCLUDE_KEYTRANSFORM prompt 4 @@ -112,10 +112,22 @@ + + {48574278-4779-4b3a-a9e4-9cf1bc285d0b} + JavaFileStorageBindings + {545b4a6b-8bba-4fbe-92fc-4ac060122a54} KeePassLib2Android + + {70d3844a-d9fa-4a64-b205-a84c6a822196} + KP2AKdbLibraryBinding + + + {5cf675a5-9bee-4720-bed9-d5bf14a2ebf9} + TwofishCipher +