Setting the HttpWebRequest.KeepAlive
to false
didn't work for me.
Since I was accessing a HTTPS page I had to set the Service Point Security Protocol to Tls12.
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
Notice that there are other SecurityProtocolTypes
: SecurityProtocolType.Ssl3
, SecurityProtocolType.Tls
, SecurityProtocolType.Tls11
So if the Tls12 doesn't work for you, try the three remaining options.
Also notice that you can set multiple protocols. This is preferable on most cases.
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
Edit: Since this is a choice of security standards it's obviously best to go with the latest (TLS 1.2 as of writing this), and not just doing what works. In fact, SSL3 has been officially prohibited from use since 2015 and TLS 1.0 and TLS 1.1 will likely be prohibited soon as well. source: @aske-b
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…