21 #elif defined(__APPLE__)
22 #include <Security/Security.h>
23 #elif defined(__ANDROID__)
28 #define DBG_NW LOG_STREAM(debug, log_network)
29 #define LOG_NW LOG_STREAM(info, log_network)
30 #define WRN_NW LOG_STREAM(warn, log_network)
31 #define ERR_NW LOG_STREAM(err, log_network)
39 HCERTSTORE hStore = CertOpenSystemStore(0, TEXT(
"ROOT"));
40 assert(hStore != NULL);
42 X509_STORE *store = X509_STORE_new();
43 PCCERT_CONTEXT pContext = NULL;
44 while ((pContext = CertEnumCertificatesInStore(hStore, pContext)) != NULL) {
45 X509 *x509 = d2i_X509(NULL,
46 const_cast<const unsigned char**
>(&pContext->pbCertEncoded),
47 pContext->cbCertEncoded);
49 X509_STORE_add_cert(store, x509);
54 CertFreeCertificateContext(pContext);
55 CertCloseStore(hStore, 0);
57 SSL_CTX_set_cert_store(ctx.native_handle(), store);
58 #elif defined(__APPLE__)
59 X509_STORE *store = X509_STORE_new();
60 CFArrayRef certs = NULL;
62 OSStatus os_status = SecTrustCopyAnchorCertificates(&certs);
66 ERR_NW <<
"Error enumerating certificates.";
74 for(CFIndex
i = 0;
i < CFArrayGetCount(certs);
i++) {
75 SecCertificateRef cert = (SecCertificateRef)CFArrayGetValueAtIndex(certs,
i);
78 CFDataRef der_cert = SecCertificateCopyData(cert);
80 ERR_NW <<
"Error getting a DER representation of a certificate.";
85 const uint8_t* der_cert_ptr = CFDataGetBytePtr(der_cert);
86 X509* x509_cert = d2i_X509(NULL, &der_cert_ptr, CFDataGetLength(der_cert));
88 ERR_NW <<
"Error deciding the X509 certificate.";
94 if(X509_STORE_add_cert(store, x509_cert) != 1) {
97 ERR_NW <<
"Error adding the X509 certificate to the store.";
103 SSL_CTX_set_cert_store(ctx.native_handle(), store);
104 #elif defined(__ANDROID__)
107 ctx.set_default_verify_paths();
Declarations for File-IO.
Standard logging facilities (interface).
void load_tls_root_certs(boost::asio::ssl::context &ctx)
static lg::log_domain log_network("network")