summaryrefslogtreecommitdiff
path: root/xmlsecurity
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2016-05-20 13:58:43 +0300
committerTor Lillqvist <tml@collabora.com>2016-05-20 15:20:28 +0300
commit2be281097fc0531a6a18835119ab406dfb8494d2 (patch)
tree793f83df34773885245b1358a2d96508dbb8c49e /xmlsecurity
parent2cf9772a3e06c156c7d0a79466db57ced7fe281d (diff)
Add SAL_INFOs of the list of system and physical cert stores
Change-Id: I5c232e72c4a7fc18bc0f7ea29a9c912bf71284ba
Diffstat (limited to 'xmlsecurity')
-rw-r--r--xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx70
1 files changed, 70 insertions, 0 deletions
diff --git a/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx
index 2717d1c6d118..84fd8e80848c 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 );