22 auto certStoreDelete = [](
void* h) {
26 std::unique_ptr<void,
decltype(certStoreDelete)> hStore{CertOpenSystemStore(0,
"ROOT"), certStoreDelete};
30 ec = boost::system::error_code(GetLastError(), boost::system::system_category());
36 std::unique_ptr<X509_STORE,
decltype(X509_STORE_free)*> store{X509_STORE_new(), X509_STORE_free};
40 ec = boost::system::error_code(
static_cast<int>(::ERR_get_error()), boost::asio::error::get_ssl_category());
47 ::ERR_error_string_n(ec.value(), buf,
sizeof(buf));
48 JLOG(j.
warn()) << msg <<
" " << buf;
52 PCCERT_CONTEXT pContext = NULL;
53 while ((pContext = CertEnumCertificatesInStore(hStore.get(), pContext)) != NULL)
55 unsigned char const* pbCertEncoded = pContext->pbCertEncoded;
57 d2i_X509(NULL, &pbCertEncoded, pContext->cbCertEncoded), X509_free};
60 warn(
"Error decoding certificate");
64 if (X509_STORE_add_cert(store.get(), x509.get()) != 1)
66 warn(
"Error adding certificate");
76 SSL_CTX_set_cert_store(ctx.native_handle(), store.release());
79 ctx.set_default_verify_paths(ec);