#include #include #include "vmime/vmime.hpp" #include "utilities.h" using namespace vmime::security::cert; vmime::shared_ptr windows_root_certs_verifier(void) { vmime::shared_ptr vrf = vmime::make_shared(); std::vector> root_certs; vmime::shared_ptr cert; HCERTSTORE store; PCCERT_CONTEXT context; store = CertOpenSystemStore(0, "ROOT"); if (store == NULL) FAIL(MSG_NO_ROOT_CA_STORE); context = NULL; while (true) { context = CertEnumCertificatesInStore(store, context); if (context == NULL) break; cert = vmime::security::cert::X509Certificate::import (context->pbCertEncoded, context->cbCertEncoded); if (cert) root_certs.push_back(cert); } CertCloseStore(store, 0); vrf->setX509RootCAs(root_certs); return vrf; }