19#include <xrpld/net/RegisterSSLCerts.h>
20#include <boost/predef.h>
23#include <boost/asio/ssl/error.hpp>
24#include <boost/system/error_code.hpp>
26#include <openssl/err.h>
27#include <openssl/ssl.h>
28#include <openssl/x509.h>
36 boost::asio::ssl::context& ctx,
37 boost::system::error_code& ec,
41 auto certStoreDelete = [](
void* h) {
46 CertOpenSystemStore(0,
"ROOT"), certStoreDelete};
50 ec = boost::system::error_code(
51 GetLastError(), boost::system::system_category());
58 X509_STORE_new(), X509_STORE_free};
62 ec = boost::system::error_code(
63 static_cast<int>(::ERR_get_error()),
64 boost::asio::error::get_ssl_category());
71 ::ERR_error_string_n(ec.value(), buf,
sizeof(buf));
72 JLOG(j.
warn()) << mesg <<
" " << buf;
76 PCCERT_CONTEXT pContext = NULL;
77 while ((pContext = CertEnumCertificatesInStore(hStore.get(), pContext)) !=
80 const unsigned char* pbCertEncoded = pContext->pbCertEncoded;
82 d2i_X509(NULL, &pbCertEncoded, pContext->cbCertEncoded), X509_free};
85 warn(
"Error decoding certificate");
89 if (X509_STORE_add_cert(store.get(), x509.get()) != 1)
91 warn(
"Error adding certificate");
101 SSL_CTX_set_cert_store(ctx.native_handle(), store.release());
104 ctx.set_default_verify_paths(ec);
116#undef X509_EXTENSIONS
118#undef PKCS7_ISSUER_AND_SERIAL
A generic endpoint for log messages.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
void registerSSLCerts(boost::asio::ssl::context &ctx, boost::system::error_code &ec, beast::Journal j)
Register default SSL certificates.