[Libreoffice-commits] core.git: 2 commits - xmlsecurity/inc xmlsecurity/source

Tor Lillqvist tml at collabora.com
Fri May 20 12:21:30 UTC 2016


 xmlsecurity/inc/xmlsecurity/certificatechooser.hxx                    |    2 
 xmlsecurity/source/dialogs/certificateviewer.cxx                      |    6 
 xmlsecurity/source/dialogs/certificateviewer.src                      |    5 
 xmlsecurity/source/dialogs/dialogs.hrc                                |    1 
 xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx |   70 ++++++++++
 5 files changed, 83 insertions(+), 1 deletion(-)

New commits:
commit c42be58e4c006ab3e1f262b644789cba8659d0ab
Author: Tor Lillqvist <tml at collabora.com>
Date:   Fri May 20 14:12:30 2016 +0300

    Show the certificate use also in the View Certificate dialog
    
    Change-Id: I25ba55456be62307348eec529bfd434f8a90bac4

diff --git a/xmlsecurity/inc/xmlsecurity/certificatechooser.hxx b/xmlsecurity/inc/xmlsecurity/certificatechooser.hxx
index 8617d05..e24c457 100644
--- a/xmlsecurity/inc/xmlsecurity/certificatechooser.hxx
+++ b/xmlsecurity/inc/xmlsecurity/certificatechooser.hxx
@@ -64,7 +64,6 @@ private:
     void ImplInitialize();
 
     void HandleOneUsageBit(OUString& string, int& bits, int bit, const char *name);
-    OUString UsageInClearText(int bits);
 
 public:
     CertificateChooser(vcl::Window* pParent, css::uno::Reference< css::uno::XComponentContext>& rxCtx, css::uno::Reference< css::xml::crypto::XSecurityEnvironment >& rxSecurityEnvironment);
@@ -77,6 +76,7 @@ public:
     /// Gets the description string provided when selecting the certificate.
     OUString GetDescription();
 
+    OUString UsageInClearText(int bits);
 };
 
 #endif // INCLUDED_XMLSECURITY_INC_XMLSECURITY_CERTIFICATECHOOSER_HXX
diff --git a/xmlsecurity/source/dialogs/certificateviewer.cxx b/xmlsecurity/source/dialogs/certificateviewer.cxx
index 21584b8..9c4e397 100644
--- a/xmlsecurity/source/dialogs/certificateviewer.cxx
+++ b/xmlsecurity/source/dialogs/certificateviewer.cxx
@@ -17,6 +17,7 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <xmlsecurity/certificatechooser.hxx>
 #include <xmlsecurity/certificateviewer.hxx>
 #include <com/sun/star/security/XCertificate.hpp>
 
@@ -278,6 +279,11 @@ CertificateViewerDetailsTP::CertificateViewerDetailsTP( vcl::Window* _pParent, C
     aLBEntry = aDetails = xCert->getSignatureAlgorithm();
     InsertElement( XMLSEC_RES( STR_SIGNATURE_ALGO ), aLBEntry, aDetails );
 
+    CertificateChooser* pChooser = dynamic_cast<CertificateChooser*>(mpDlg->GetParent());
+    assert(pChooser);
+    aLBEntry = pChooser->UsageInClearText( mpDlg->mxCert->getCertificateUsage() );
+    InsertElement( XMLSEC_RES( STR_USE ), aLBEntry, aLBEntry );
+
     aSeq = xCert->getSHA1Thumbprint();
     aLBEntry = XmlSec::GetHexString( aSeq, pHexSep );
     aDetails = XmlSec::GetHexString( aSeq, pHexSep, nLineBreak );
diff --git a/xmlsecurity/source/dialogs/certificateviewer.src b/xmlsecurity/source/dialogs/certificateviewer.src
index 24e8246..a62c50d 100644
--- a/xmlsecurity/source/dialogs/certificateviewer.src
+++ b/xmlsecurity/source/dialogs/certificateviewer.src
@@ -86,6 +86,11 @@ String STR_SIGNATURE_ALGO
     Text [ en-US ] = "Signature Algorithm";
 };
 
+String STR_USE
+{
+    Text [ en-US ] = "Certificate Use";
+};
+
 String STR_THUMBPRINT_SHA1
 {
     Text [ en-US ] = "Thumbprint SHA1";
diff --git a/xmlsecurity/source/dialogs/dialogs.hrc b/xmlsecurity/source/dialogs/dialogs.hrc
index af7b206..65cceb6 100644
--- a/xmlsecurity/source/dialogs/dialogs.hrc
+++ b/xmlsecurity/source/dialogs/dialogs.hrc
@@ -38,6 +38,7 @@
 #define STR_SIGNATURE_ALGO              266
 #define STR_THUMBPRINT_SHA1             267
 #define STR_THUMBPRINT_MD5              268
+#define STR_USE                         271
 
 // --------- general metrics ---------
 #define DLGS_WIDTH                      287
commit 2be281097fc0531a6a18835119ab406dfb8494d2
Author: Tor Lillqvist <tml at collabora.com>
Date:   Fri May 20 13:58:43 2016 +0300

    Add SAL_INFOs of the list of system and physical cert stores
    
    Change-Id: I5c232e72c4a7fc18bc0f7ea29a9c912bf71284ba

diff --git a/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx
index 2717d1c..84fd8e8 100644
--- a/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx
+++ b/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx
@@ -43,6 +43,7 @@
 
 #include <xmlsecurity/biginteger.hxx>
 
+#include <comphelper/windowserrorstring.hxx>
 #include <sal/log.hxx>
 #include <rtl/locale.h>
 #include <osl/nlsupport.h>
@@ -366,6 +367,71 @@ HCRYPTKEY SecurityEnvironment_MSCryptImpl::getPriKey( unsigned int position ) th
     return prikey ;
 }
 
+#ifdef SAL_LOG_INFO
+
+// Based on sample code from MSDN
+
+static void get_system_name(const void *pvSystemStore,
+                            DWORD dwFlags,
+                            LPCWSTR *ppwszSystemName)
+{
+    *ppwszSystemName = NULL;
+
+    if (dwFlags & CERT_SYSTEM_STORE_RELOCATE_FLAG)
+    {
+        PCERT_SYSTEM_STORE_RELOCATE_PARA pRelocatePara;
+        pRelocatePara = (PCERT_SYSTEM_STORE_RELOCATE_PARA) pvSystemStore;
+        *ppwszSystemName = pRelocatePara->pwszSystemStore;
+    }
+    else
+    {
+        *ppwszSystemName = (LPCWSTR) pvSystemStore;
+    }
+}
+
+extern "C" BOOL WINAPI cert_enum_physical_store_callback(const void *,
+                                                         DWORD dwFlags,
+                                                         LPCWSTR pwszStoreName,
+                                                         PCERT_PHYSICAL_STORE_INFO,
+                                                         void *,
+                                                         void *)
+{
+    OUString name(pwszStoreName);
+    if (dwFlags & CERT_PHYSICAL_STORE_PREDEFINED_ENUM_FLAG)
+        name += " (implicitly created)";
+    SAL_INFO("xmlsecurity.xmlsec", "  Physical store: " << name);
+
+    return TRUE;
+}
+
+extern "C" BOOL WINAPI cert_enum_system_store_callback(const void *pvSystemStore,
+                                                       DWORD dwFlags,
+                                                       PCERT_SYSTEM_STORE_INFO,
+                                                       void *,
+                                                       void *)
+{
+    LPCWSTR pwszSystemStore;
+
+    get_system_name(pvSystemStore, dwFlags, &pwszSystemStore);
+    SAL_INFO("xmlsecurity.xmlsec", "System store: " << OUString(pwszSystemStore));
+
+    if (!CertEnumPhysicalStore(pvSystemStore,
+                               dwFlags,
+                               NULL,
+                               cert_enum_physical_store_callback))
+    {
+        DWORD dwErr = GetLastError();
+        if (!(ERROR_FILE_NOT_FOUND == dwErr ||
+              ERROR_NOT_SUPPORTED == dwErr))
+        {
+            SAL_WARN("xmlsecurity.xmlsec", "CertEnumPhysicalStore failed:" << WindowsErrorString(GetLastError()));
+        }
+    }
+    return TRUE;
+}
+
+#endif
+
 //Methods from XSecurityEnvironment
 Sequence< Reference < XCertificate > > SecurityEnvironment_MSCryptImpl::getPersonalCertificates() throw( SecurityException , RuntimeException )
 {
@@ -397,6 +463,10 @@ Sequence< Reference < XCertificate > > SecurityEnvironment_MSCryptImpl::getPerso
         DWORD      dwKeySpec;
         HCRYPTPROV hCryptProv;
 
+#ifdef SAL_LOG_INFO
+        CertEnumSystemStore(CERT_SYSTEM_STORE_CURRENT_USER, NULL, NULL, cert_enum_system_store_callback);
+#endif
+
         hSystemKeyStore = CertOpenSystemStore( 0, "MY" ) ;
         if( hSystemKeyStore != NULL ) {
             pCertContext = CertEnumCertificatesInStore( hSystemKeyStore, pCertContext );


More information about the Libreoffice-commits mailing list