I want to let the ie's IWebBrowser didn't need to select the certificate, so I use InternetSetOption()
to do that. The code is:
HCERTSTORE hMyStore = CertOpenSystemStore(0, _T("MY");
PCCERT_CONTEXT pDesiredCert = NULL;
pDesiredCert=CertFindCertificateInStore(
hMyStore,
X509_ASN_ENCODING | PKCS_7_ASN_ENCODING,
CERT_FIND_SUBJECT_STR,
L"cnstr",
NULL);
if (InternetSetOption (NULL, INTERNET_OPTION_CLIENT_CERT_CONTEXT,
(LPVOID)pDesiredCert, sizeof(CERT_CONTEXT)) == FALSE) {
DOWRD i = GetLastError();
}
...
I get the certificate in the "MY" store. When I use InternetSetOption()
to set the certificate, it return false, the error code is 12018. I searched some infomation about this error code:
"12018 ERROR_INTERNET_INCORRECT_HANDLE_TYPE The type of handle supplied is incorrect for this operation."
I want to set the global setting, so I set NULL to the first parameter, does the first parameter in the function InternetSetOption()
couldn't be NULL
? And how could I set the option correctly?