-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Hi,
I have used below code using WinHTTP to use certificate, but now I moved to CPPRESTSDK and want to set the certificate for HTTPS but I am not getting any option in REST API. or its automatically verified when using HTTPS connection and set_validate_certificates(true);
Please suggest if my understanding is correct or not.
OS- Windows
hRequest = WinHttpOpenRequest(hConnect, L"POST", L"/auth",
NULL, WINHTTP_NO_REFERER,
WINHTTP_DEFAULT_ACCEPT_TYPES,
NULL);
//WINHTTP_FLAG_SECURE);
/hRequest = WinHttpOpenRequest(hConnect, L"POST", L"/auth",
L"HTTP/1.1", WINHTTP_NO_REFERER,
WINHTTP_DEFAULT_ACCEPT_TYPES,
WINHTTP_FLAG_REFRESH);
WINHTTP_FLAG_SECURE);/
if (!hRequest) {
Clog::traceLog(ERRORLOG, "WinHttpOpenRequest:Error %d has occurred.", GetLastError());
iRetVal = SDP_ERROR_WINHTTP_INTERNAL_ERROR;
}
else {
hMyStore = CertOpenSystemStore(0, TEXT("MY"));
if (hMyStore)
{
pCertContext = CertFindCertificateInStore(hMyStore,
X509_ASN_ENCODING | PKCS_7_ASN_ENCODING,
0,
CERT_FIND_SUBJECT_STR,
(LPVOID)szCertName, //Subject string in the certificate.
NULL);
if (!pCertContext)
{
WinHttpSetOption(hRequest,
WINHTTP_OPTION_CLIENT_CERT_CONTEXT,
(LPVOID)pCertContext,
sizeof(CERT_CONTEXT));
CertFreeCertificateContext(pCertContext);
}
CertCloseStore(hMyStore, 0);
Thanks,
Shivendra