Click here to Skip to main content
15,887,434 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
IWinHttpRequest interface was working fine until TLS version has been changed from Server side. TLS version of server has been changed to TLSv1.1 and higher.

because of this change I am not able to get any response from server.

So I decided to use WinHttpSetOption to set protocol version. but it doesn't work.

Please anybody can help me?

What I have tried:

IWinHttpRequest interface was working fine until TLS version has been changed from Server side. TLS version of server has been changed to TLSv1.1 and higher.

because of this change I am not able to get any response from server.

So I decided to use WinHttpSetOption to set protocol version. but it doesn't work.

The below code is where I set the options.

dwVal = WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_1 | WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_2; 
bRet = WinHttpSetOption(request_,WINHTTP_OPTION_SECURE_PROTOCOLS,&dwVal,sizeof(dwVal)); 
if(!bRet)
{ 
TRACE("error - " , GetLastError());

	break; 
}



The above code doers not yield any error code although the return code for setoption is zero.
Posted
Updated 3-Jan-17 17:18pm
v2
Comments
Jochen Arndt 2-Jan-17 7:11am    
How do you call WinHttpSetOption (show code with parameters and related variables)?

What is the error code (call GetLastError)?

Please use the green "Improve question" link to add this information to your question.
Jochen Arndt 3-Jan-17 2:46am    
TRACE("error - " , GetLastError());

will get the error code but does not print it.

Use:

TRACE("error - %d\n" , GetLastError());

You must have done something wrong. Read the documentation on Option Flags for WinHttpSetOption. The value WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_1 should be right for you.

If it doesnt help ask with GetLastError() about the error code to figure it out.
 
Share this answer
 
Thanks for the help.
I got it working.
I found that WinHttpSetOption function requires The HINTERNET handle on which to set data. This can be either a Session handle or a Request handle, depending on what option is being set. And for option WINHTTP_OPTION_SECURE_PROTOCOLS we have to give Session handle.
In my above code I have given request handle and cause of that, its not working.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900