20#if defined(_WIN32) || defined(_WIN64)
21 HCERTSTORE hStore = CertOpenSystemStore(0,
"ROOT");
22 if (hStore ==
nullptr)
25 X509_STORE* store = X509_STORE_new();
26 PCCERT_CONTEXT pContext =
nullptr;
27 while ((pContext = CertEnumCertificatesInStore(hStore, pContext)) !=
nullptr)
30 X509* x509 = d2i_X509(
nullptr, (
const unsigned char**)&pContext->pbCertEncoded, pContext->cbCertEncoded);
33 X509_STORE_add_cert(store, x509);
38 CertFreeCertificateContext(pContext);
39 CertCloseStore(hStore, 0);
42 SSL_CTX_set_cert_store(native_handle(), store);
void set_root_certs()
Configures the context to use system root certificates.