Re: [asio-users] Windows certificate store
Brought to you by:
chris_kohlhoff
From: Joseph S. <jso...@se...> - 2020-01-31 21:08:47
|
You can do it something like this: pstore_ = X509_STORE_new(); SSL_load_error_strings(); sslCertStoreLoad_WinStore("CA"); sslCertStoreLoad_WinStore("MY"); sslCertStoreLoad_WinStore("ROOT"); sslCertStoreLoad_WinStore("SPC"); sslCertStoreLoad_WinStore("TrustedPeople"); sslCertStoreLoad_WinStore("TrustedPublisher"); SSL_CTX_set_cert_store(ctx.native_handle(), pstore_); where sslCertStoreLoad_WinStore is something like void sslCertStoreLoad_WinStore(const char *winStoreName) { HCERTSTORE winStore = CertOpenStore( CERT_STORE_PROV_SYSTEM_A, X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, 0, CERT_SYSTEM_STORE_LOCAL_MACHINE|CERT_STORE_READONLY_FLAG, (const void*)winStoreName); if(winStore == NULL) { return; } PCCERT_CONTEXT certCtx = NULL; while((certCtx = CertEnumCertificatesInStore(winStore, certCtx)) != NULL) { TCHAR szName[MAX_PATH] = { 0 }; X509 *cert = d2i_X509(NULL, (OPENSSL_d2i_TYPE)&certCtx->pbCertEncoded, certCtx->cbCertEncoded); X509_STORE_add_cert(pstore_, cert); X509_free(cert); } CertCloseStore(winStore, 0); } On 1/30/2020 4:29 PM, Jeffrey Chen wrote: > Hi, > asio supports SSL by providing certificate private/public keys or > certificate files path. However, in the Windows world, this is not the > common pattern. Windows has the certificate store. It takes care the > encryption/decryption for you. Is there a sample to interact asio with > the Windows certificate store? > > > > > _______________________________________________ > asio-users mailing list > asi...@li... > https://lists.sourceforge.net/lists/listinfo/asio-users > _______________________________________________ > Using Asio? List your project at > http://think-async.com/Asio/WhoIsUsingAsio |