Certificate client with webdav
A lightweight and easy-to-use password manager
Brought to you by:
dreichl
Hello !
I have enhanced the access to my WebDAV server with a client certificate.
When loading, saving or synchronizing with an url using https (WebDAV) KeePass does not use my client certificate from the Windows Store and return an error n°400.
In reviewing the source it appears that this is done intentionally to allow client certificates.
The following patch find the certificate in the Windows store and use it.
Please let me know if you prefer the patch in a different format.
diff --git a/KeePassLib/Serialization/IOConnection.cs b/KeePassLib/Serialization/IOConnection.cs
index 7459af7..415a626 100644
--- a/KeePassLib/Serialization/IOConnection.cs
+++ b/KeePassLib/Serialization/IOConnection.cs
@@ -310,6 +310,12 @@ namespace KeePassLib.Serialization
if(IsHttpWebRequest(request))
{
// WebDAV support
+^M
+ // Client certificate support^M
+ // Use the X509Store class to get a handle to the local certificate stores. "My" is the "Personal" store.^M
+ X509Store store = new X509Store(StoreName.My, StoreLocation.LocalMachine);^M
+ store.Open(OpenFlags.ReadOnly);^M
+ request.ClientCertificates = store.Certificates.Find(X509FindType.FindBySubjectName, request.Host, true);^M
#if !KeePassUAP
request.PreAuthenticate = true; // Also auth GET
#endif
Moving to patches.
Thanks and best regards,
Dominik
Ticket moved from /p/keepass/bugs/1850/