I'm trying to request this image: https://www.kamerstunt.nl/file/img/web/woning/9577323WenumWieselZwolseweg-142d_6.jpg If the image no longer exists when you read this, it might have been removed, but you'd still be able to view the SSL certificate in question. Using my browser I was able to successfully navigate to the page, request the image and see a valid SSL certificate.
I checked here: The request was aborted: Could not create SSL/TLS secure channel
So I added that solution to my code:
Dim imgRequest As WebRequest = WebRequest.Create("https://www.kamerstunt.nl/file/img/web/woning/9577323WenumWieselZwolseweg-142d_6.jpg")
Dim imgResponse As WebResponse
ServicePointManager.Expect100Continue = True
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls
'//I also tried: ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls Or SecurityProtocolType.Ssl3
imgResponse = imgRequest.GetResponse()
Dim streamPhoto As Stream = imgResponse.GetResponseStream()
I tried:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 Or SecurityProtocolType.Tls Or SecurityProtocolType.Tls11 Or SecurityProtocolType.Tls12
But then I get errors:
'Tls12' is not a member of 'System.Net.SecurityProtocolType' and
'Tls11' is not a member of 'System.Net.SecurityProtocolType'
I also tried to change the registry to allow windows to not block DHE with 512 bits and added ClientMinKeyBitLength with 0x00000200(512) value under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\KeyExchangeAlgorithms\Diffie-Hellman.
But still it fails...why?
Here is a solution I use that returns a
Stream... You can also modify it so it returns a byte array and then create a new MemoryStream from that byte array. Also instead of a string type to pass you can change it to a url, but that's up to you.Example Usage
EDIT PLEASE READ ********************************************
After looking into this and digging a little further, I found a solution. It seem's that the site has dropped support for SSL & Tls11.
I started a new project targeting 4.5 framework. I then used this
SecurityProtocolType...Solution
Change the target framework to: 4.5 and use: SecurityProtocolType.Tls12. Now your protocol should look like this...
On another note
I recommend wrapping your
Streamso it get's properly disposed of. For example:Here's proof of my output...