SSL exception on Windows 7
public static T Rest<T>(string baseAddress, int requestTimeoutSeconds, params string[] defaultRequestHeaders)
{
var httpClientHandler = new HttpClientHandler { ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => { return true; } };
var httpClient = new HttpClient(httpClientHandler)
{
BaseAddress = new Uri(baseAddress),
Timeout = TimeSpan.FromSeconds(requestTimeoutSeconds),
};
for (int i = 0; i < defaultRequestHeaders.Length; i += 2)
{
if (defaultRequestHeaders[i] != null)
{
httpClient.DefaultRequestHeaders.Remove(defaultRequestHeaders[i]);
httpClient.DefaultRequestHeaders.Add(defaultRequestHeaders[i], defaultRequestHeaders[i + 1]);
}
}
return new RestClient(httpClient).For<T>();
}
public interface IApi
{
[Post("/login")]
Task<api_token> LoginAsync();
}
var apiLogin = U_COMMON.Rest<IApi>("https://api.myservice.com:4443", 30, "Authorization", $"Basic <some-credential>");
var token = await apiLogin.LoginAsync();
- the app is x86 assembly with .NET 5.0
- .NET 5.0 runtimes are installed (both x86 and x64)
- .NET framework 4.8 is installed
it works with Win10 x64 but with Win7 Sp1 x64 it generates:
The SSL connection could not be established, see inner exception.
-
the inner exception is empty
-
I've already added these registry entries:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Client] "DisabledByDefault"=dword:00000000 "Enabled"=dword:00000001
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1\Client] "DisabledByDefault"=dword:00000000 "Enabled"=dword:00000001
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client] "DisabledByDefault"=dword:00000000 "Enabled"=dword:00000001
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.3\Client] "DisabledByDefault"=dword:00000000 "Enabled"=dword:00000001
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\WinHttp] "DefaultSecureProtocols"=dword:0xAA0 [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Internet Settings\WinHttp] "DefaultSecureProtocols"=dword:0xAA0
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft.NETFramework\v2.0.50727] "SystemDefaultTlsVersions"=dword:00000001 "SchUseStrongCrypto"=dword:00000001 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft.NETFramework\v4.0.30319] "SystemDefaultTlsVersions"=dword:00000001 "SchUseStrongCrypto"=dword:00000001
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft.NETFramework\v2.0.50727] "SystemDefaultTlsVersions"=dword:00000001 "SchUseStrongCrypto"=dword:00000001 [HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft.NETFramework\v4.0.30319] "SystemDefaultTlsVersions"=dword:00000001 "SchUseStrongCrypto"=dword:00000001
This exception is being thrown by the underlying HttpClient -- it's not caused by RestEase. You should be able to replicate it by using a HttpClient directly.
I'm afraid I can't help here.