27 auto certStoreDelete = [](
void* h) {
32 CertOpenSystemStore(0,
"ROOT"), certStoreDelete};
36 ec = boost::system::error_code(GetLastError(), boost::system::system_category());
43 X509_STORE_new(), X509_STORE_free};
47 ec = boost::system::error_code(
48 static_cast<int>(::ERR_get_error()), boost::asio::error::get_ssl_category());
55 ::ERR_error_string_n(ec.value(), buf,
sizeof(buf));
56 JLOG(j.
warn()) << msg <<
" " << buf;
60 PCCERT_CONTEXT pContext = NULL;
61 while ((pContext = CertEnumCertificatesInStore(hStore.get(), pContext)) != NULL)
63 unsigned char const* pbCertEncoded = pContext->pbCertEncoded;
65 d2i_X509(NULL, &pbCertEncoded, pContext->cbCertEncoded), X509_free};
68 warn(
"Error decoding certificate");
72 if (X509_STORE_add_cert(store.get(), x509.get()) != 1)
74 warn(
"Error adding certificate");
84 SSL_CTX_set_cert_store(ctx.native_handle(), store.release());
88 ctx.set_default_verify_paths(ec);