I am working on a web scraping program and I am getting the following error on sites that have Tls 1.0 and 1.1 disabled, and Tls 1.2 and 1.3 enabled:
'The request was aborted: Could not create SSL/TLS secure channel'
I should also note that I am using .Net version 4.8
This is the site that I am using to check: https://www.cdn77.com/tls-test
I've read nearly a dozen posts on the topic and none of the solutions have worked for me.
This is the code. It works on most sites:
Try
ServicePointManager.Expect100Continue = True
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 Or
SecurityProtocolType.Tls13
Dim address = New Uri(url)
Using client = New WebClient()
Dim stream = client.OpenRead(address) ' This is where exception is caught
Using sr = New StreamReader(stream)
Dim page = sr.ReadToEnd()
Return page
End Using
End Using
Catch ex As Exception
Return ex.Message
End Try