22 auto certStoreDelete = [](
void* h) {
27 CertOpenSystemStore(0,
"ROOT"), certStoreDelete};
31 ec = boost::system::error_code(GetLastError(), boost::system::system_category());
38 X509_STORE_new(), X509_STORE_free};
42 ec = boost::system::error_code(
43 static_cast<int>(::ERR_get_error()), boost::asio::error::get_ssl_category());
50 ::ERR_error_string_n(ec.value(), buf,
sizeof(buf));
51 JLOG(j.
warn()) << msg <<
" " << buf;
55 PCCERT_CONTEXT pContext = NULL;
56 while ((pContext = CertEnumCertificatesInStore(hStore.get(), pContext)) != NULL)
58 unsigned char const* pbCertEncoded = pContext->pbCertEncoded;
60 d2i_X509(NULL, &pbCertEncoded, pContext->cbCertEncoded), X509_free};
63 warn(
"Error decoding certificate");
67 if (X509_STORE_add_cert(store.get(), x509.get()) != 1)
69 warn(
"Error adding certificate");
79 SSL_CTX_set_cert_store(ctx.native_handle(), store.release());
83 ctx.set_default_verify_paths(ec);