WinHttpClientException

Hi Wagner,

I did access partner api rest but got an error message like this? This error occurs only on one server with server OS 2008 R2 SP1, while on Windows 10 and Windows Server 2016 the error does not occur.

image

Thank you

the problem is solved with me installing the windows patch on the following link.
https://support.microsoft.com/en-us/help/3140245/update-to-enable-tls-1-1-and-tls-1-2-as-default-secure-protocols-in-wi

After this partner rest api solved, now the other partner rest api have a problem with same error message. I know there is a problem with the configuration of the tls secure protocol on my server. but I have not found how to fix it.

Well, yes, Windows Server 2008 is already very old, probably it doesn't support the modern TLS used by the server it's trying to access. Maybe the following information might help.

You must first make sure you have update 3140245 installed in Windows 7. See link below.
https://support.microsoft.com/en-ca/help/3140245/update-to-enable-tls-1-1-and-tls-1-2-as-default-secure-protocols-in-wi

Then, you can enable TLS 1.1 and 1.2 in WinHttp either from code, using Sparkle:

    OptionValue := 
      WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_1 or WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_2;
    if not WinHttpSetOption(
      TWinHttpEngine(Client.Engine).Session,
      WINHTTP_OPTION_SECURE_PROTOCOLS, @OptionValue, SizeOf(OptionValue)) then
      WinHttpCheck(False);

Or you can create specific registry keys to enable TLS1.1 and TLS 1.2 for all applications without you having to change its code. It’s described in the link above, you have to create the DefaultSecureProtocols registry value in either

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\WinHttp
or
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Internet Settings\WinHttp

depending on your OS version.