I have an existing dotnet 4.7.1 application running on Windows server 2012 R2 which is making Rest calls and its working fine.
We are migrating to Windows server 2019, the same application is failing at Rest calls with error The request was aborted: Could not create SSL/TLS secure channel.
When I use ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
before the rest call it works fine. I logged ServicePointManager.SecurityProtocol
on both the servers as well as my local machine Windows 11 Enterprise 22H2, it gives following output.
- Windows Server 2012 R2 gives Tls,Tls11,Tls12,Tls13
- Windows Server 2019 gives Ssl3,Tls
- Windows 11 Enterprise 22H2 gives Ssl3,Tls
Ideally Windows Server 2019 & Windows 11 should have worked without any code changes.
Referred following links but still not able to understand why is it working like this.
Thanks in advance.
Referred:
- Why ServicePointManager.SecurityProtocol default value is different on different machines?
- https://learn.microsoft.com/en-us/dotnet/api/system.net.servicepointmanager.securityprotocol?view=net-8.0&redirectedfrom=MSDN#System_Net_ServicePointManager_SecurityProtocol
- https://learn.microsoft.com/en-us/windows/win32/secauthn/protocols-in-tls-ssl–schannel-ssp-