Default SecurityProtocol
ใน .NET 4.5 คือ SSL 3
และ TLS 1.0
ServicePointManager.SecurityProtocol =
SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls
การเชื่อมต่อผ่าน HTTPS จึงทำได้กับ Website ที่ Support SSL 3
หรือ TLS 1.0
เท่านั้น เช่น Website ด้านล่างที่ Support TLS 1.0
TLS 1.1
และ TLS 1.2
แต่ เนื่องจาก SSL 3
และ TLS 1.0
เป็น Protocol รุ่นเก่าที่มีปัญหาด้านความปลอดภัย บาง Website จึงเปลี่ยนไปใช้ Protocol ที่ใหม่กว่า เช่น TLS 1.1
และ TLS 1.2
โดยไม่ Support SSL 3
และ TLS 1.0
อีกต่อไป
โปรแกรม .NET 4.5 จะใช้งานไม่ได้ เกิด HttpRequestException: Could not create SSL/TLS secure channel
วิธีแก้
ต้องปรับค่า Protocol ใหม่ โดยเปลี่ยน SecurityProtocol
ในคลาส ServicePointManager
เป็น TLS 1.1
หรือ TLS 1.2
ServicePointManager.SecurityProtocol =
SecurityProtocolType.Tls11
| SecurityProtocolType.Tls12
วิธีตรวจสอบว่า Website Support Protocol เวอร์ชันใดบ้าง ให้เข้าไปที่ https://www.ssllabs.com/ssltest