Для тех из вас, кто до сих пор борется с этим, как я, вот пример кода, с которого можно начать:
#include <stdio.h>
#include <windows.h>
#include <wincrypt.h>
#include <cryptuiapi.h>
#include <iostream>
#include <tchar.h>
#include "openssl\x509.h"
#pragma comment (lib, "crypt32.lib")
#pragma comment (lib, "cryptui.lib")
#define MY_ENCODING_TYPE (PKCS_7_ASN_ENCODING | X509_ASN_ENCODING)
int main(void)
{
HCERTSTORE hStore;
PCCERT_CONTEXT pContext = NULL;
X509 *x509;
X509_STORE *store = X509_STORE_new();
hStore = CertOpenSystemStore(NULL, L"ROOT");
if (!hStore)
return 1;
while (pContext = CertEnumCertificatesInStore(hStore, pContext))
{
//uncomment the line below if you want to see the certificates as pop ups
//CryptUIDlgViewContext(CERT_STORE_CERTIFICATE_CONTEXT, pContext, NULL, NULL, 0, NULL);
x509 = NULL;
x509 = d2i_X509(NULL, (const unsigned char **)&pContext->pbCertEncoded, pContext->cbCertEncoded);
if (x509)
{
int i = X509_STORE_add_cert(store, x509);
if (i == 1)
std::cout << "certificate added" << std::endl;
X509_free(x509);
}
}
CertFreeCertificateContext(pContext);
CertCloseStore(hStore, 0);
system("pause");
return 0;
}