39 boost::asio::ssl::context& ctx,
40 boost::system::error_code& ec,
44 auto certStoreDelete = [](
void* h) {
49 CertOpenSystemStore(0,
"ROOT"), certStoreDelete};
53 ec = boost::system::error_code(
54 GetLastError(), boost::system::system_category());
61 X509_STORE_new(), X509_STORE_free};
65 ec = boost::system::error_code(
66 static_cast<int>(::ERR_get_error()),
67 boost::asio::error::get_ssl_category());
74 ::ERR_error_string_n(ec.value(), buf,
sizeof(buf));
75 JLOG(j.
warn()) << mesg <<
" " << buf;
79 PCCERT_CONTEXT pContext = NULL;
80 while ((pContext = CertEnumCertificatesInStore(hStore.get(), pContext)) !=
83 unsigned char const* pbCertEncoded = pContext->pbCertEncoded;
85 d2i_X509(NULL, &pbCertEncoded, pContext->cbCertEncoded), X509_free};
88 warn(
"Error decoding certificate");
92 if (X509_STORE_add_cert(store.get(), x509.get()) != 1)
94 warn(
"Error adding certificate");
104 SSL_CTX_set_cert_store(ctx.native_handle(), store.release());
107 ctx.set_default_verify_paths(ec);