WinHTTP WINHTTP_CALLBACK_STATUS_FLAG_SECURITY_CHANNEL_ERROR on Win7

  • Thread starter Thread starter NKJB
  • Start date Start date
N

NKJB

Guest
Hi guys

I have been bashing my head on this problem now for a couple weeks. I know it is not my code because the same code works fine on my Win10 laptop but always fails on Win7.

hSess = WinHttpOpen(NULL, WINHTTP_ACCESS_TYPE_DEFAULT_PROXY, WINHTTP_NO_PROXY_NAME, WINHTTP_NO_PROXY_BYPASS, NULL);
if (hSess)
hConn = WinHttpConnect(hSess, web_server, (ssl == true ? INTERNET_DEFAULT_HTTPS_PORT : INTERNET_DEFAULT_HTTP_PORT), NULL);
else
retcode = -1;
if (hConn)
hReq = WinHttpOpenRequest(hConn, NULL, object, NULL, WINHTTP_NO_REFERER, accepted_types, (ssl == true ? WINHTTP_FLAG_SECURE : NULL));
else
retcode = -1;

DWORD sec = WINHTTP_FLAG_SECURE_PROTOCOL_ALL | WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_1 | WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_2;
WinHttpSetOption(hReq, WINHTTP_OPTION_SECURE_PROTOCOLS, &sec, sizeof(sec));

WinHttpSetStatusCallback(hReq, _WinhttpStatusCallback, WINHTTP_CALLBACK_FLAG_SECURE_FAILURE, NULL);

if (hReq)
res = WinHttpSendRequest(hReq, WINHTTP_NO_ADDITIONAL_HEADERS, NULL, WINHTTP_NO_REQUEST_DATA, NULL, NULL, NULL);
else
retcode = -1;

The above code fails on the WinHttpSendRequest call. The flag returned by GetLastError is ERROR_WINHTTP_SECURE_FAILURE, and the WinHttpStatusCallback status information flag is WINHTTP_CALLBACK_STATUS_FLAG_SECURITY_CHANNEL_ERROR.

I have checked the registry settings for TLS and SSL and all are correct. I also ran the update KB3140245 for Win7 but to no avail.

I also tried disabling SSL by using the INTERNET_DEFAULT_HTTP_PORT in my flag instead of HTTPS for the WinHttpConnect call but no success either.

However, if I go to the URL that I am trying to connect to in my browser, it connects with https without a problem.

Any ideas?

Continue reading...
 
Back
Top