Page 1 of 1

.NET-The request was aborted: Could not create SSL/TLS..

Posted: Tue Jun 25, 2019 9:31 am
by roadmusic
When developing in .NET 4.0+ when making a POST call was I getting this error:
"The request was aborted: Could not create SSL/TLS secure channel."

I was able to fix it by adding one of these to the httpwebRequest object.

ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072; //TLS 1.2
ServicePointManager.SecurityProtocol = (SecurityProtocolType)768; //TLS 1.1

ServicePointManager.Expect100Continue = True
ServicePointManager.SecurityProtocol = CType(3072, SecurityProtocolType) ' TLS 1.2
myWebRequest = DirectCast(WebRequest.Create(baseUri.ToString), HttpWebRequest)
myWebRequest.Method = "POST"

If the above does not fix it then use this also:
https://stackoverflow.com/questions/337 ... ect=1&lq=1

Make the following changes in your Registry and it should work:
1.) .NET Framework strong cryptography registry keys
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319]
"SchUseStrongCrypto"=dword:00000001
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319]
"SchUseStrongCrypto"=dword:00000001
2.) Secure Channel (Schannel) TLS 1.2 registry keys
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2]
[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.2\Server]
"DisabledByDefault"=dword:00000000
"Enabled"=dword:00000001