如何設定 .NET Framework 支援 TLS 1.2
3.5.1或以下版本,無法支援,建議更新版本至4.6以上版本
如為4.0版本,無法支援,請額外安裝4.5.2以上之版本,
並參考以下範例修改,程式修改或系統機碼設定擇一即可
程式修改參考:
ServicePointManager.SecurityProtocol = (SecurityProtocolType)768 | (SecurityProtocolType)3072;
系統機碼設定參考:
如為.Net Framework4.5.2版本,請參考以下範例修改,程式修改或系統機碼設定擇一即可
程式修改參考:
//Creating the Web Request.
HttpWebRequest httpWebRequest = null;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(AcceptAllCertifications);
httpWebRequest = WebRequest.Create(requestUrl) as HttpWebRequest;
httpWebRequest.ProtocolVersion = HttpVersion.Version10;
系統機碼設定參考:
如為4.6版本以上版本無須修改