Menu

#117 Certificate client with webdav

KeePass_2.x
open
nobody
5
2019-05-13
2019-05-13
1mm0rt41PC
No

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

Discussion

  • Dominik Reichl

    Dominik Reichl - 2019-05-13

    Moving to patches.

    Thanks and best regards,
    Dominik

     
  • Dominik Reichl

    Dominik Reichl - 2019-05-13

    Ticket moved from /p/keepass/bugs/1850/

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.