I have an application coded in VB.net that has this method of accessing Webservice, i have this error and after searching fixes i still have no luck.
Error: The requ
I'm going to add something here in case it helps others. I have to support some legacy code that is written in VB.Net and targets .NET Framework 4.6.1. The same piece of code runs in both an .exe, and in IIS as a web page.
In the website, this call:
Dim dataStream As Stream = request.GetRequestStream()
would throw this exception
The request was aborted: Could not create SSL/TLS secure channel.
but it worked fine in the .exe.
Forcing the TLS protocol fixed it in the website.
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
Of course if the host ever deems TLS 1.2 unworthy I'll have to fix/recompile/redeploy, but it solved the error for now.
Obviously the URL you're calling requires TLS 1.1
or TLS 1.2
.
You can enable TLS 1.1
or TLS 1.2
by setting the security-protocol with ServicePointManager.SecurityProtocol
:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
.NET 4.0
supports up toTLS 1.0
while.NET 4.5
or higher supports up toTLS 1.2
For reference:
- Default SecurityProtocol in .NET 4.5
- Are there .NET implementation of TLS 1.2?