aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/security
diff options
context:
space:
mode:
authorGravatar Hoà V. DINH <dinh.viet.hoa@gmail.com>2014-11-25 00:14:32 -0800
committerGravatar Hoà V. DINH <dinh.viet.hoa@gmail.com>2014-11-25 00:14:32 -0800
commit940227a204c088179b1c42f4ccc985c1bced22c4 (patch)
tree793b936791dc968bb6eee0377aa05ff2bcedc057 /src/core/security
parent5041e67cf4ee111e9e5f14a9e06f0a598b3eb9ac (diff)
Makes the certificate verification just works on win32.
Diffstat (limited to 'src/core/security')
-rw-r--r--src/core/security/MCCertificateUtils.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/core/security/MCCertificateUtils.cpp b/src/core/security/MCCertificateUtils.cpp
index 42b75916..f2345e90 100644
--- a/src/core/security/MCCertificateUtils.cpp
+++ b/src/core/security/MCCertificateUtils.cpp
@@ -110,7 +110,26 @@ err:
goto free_certs;
}
- status = X509_STORE_set_default_paths(store);
+#ifdef _MSC_VER
+ HCERTSTORE systemStore = CertOpenSystemStore(NULL, L"ROOT");
+
+ PCCERT_CONTEXT previousCert = NULL;
+ while (1) {
+ PCCERT_CONTEXT nextCert = CertEnumCertificatesInStore(systemStore, previousCert);
+ if (nextCert == NULL) {
+ break;
+ }
+ X509 * openSSLCert = d2i_X509(NULL, (const unsigned char **)&nextCert->pbCertEncoded, nextCert->cbCertEncoded);
+ if (openSSLCert != NULL) {
+ X509_STORE_add_cert(store, openSSLCert);
+ X509_free(openSSLCert);
+ }
+ previousCert = nextCert;
+ }
+ CertCloseStore(systemStore, 0);
+#endif
+
+ status = X509_STORE_set_default_paths(store);
if (status != 1) {
printf("Error loading the system-wide CA certificates");
}