從 .NET Framework 4.6 開始, System.Net.ServicePointManager 和 System.Net.Security.SslStream 類別可以使用下列三種通訊協定之一:Tls1.0、Tls1.1 或 Tls 1.2。 不支援 SSL3.0 通訊協定與 RC4 編碼器。
影響
這項變更會影響:
任何使用 SSL 與 HTTPS 伺服器或套接字伺服器通訊的應用程式,都使用下列任何類型: HttpClient、 HttpWebRequest、 FtpWebRequest、 SmtpClient和 SslStream。
無法升級以支援 Tls1.0、Tls1.1 或 Tls 1.2.的任何伺服器端應用程式。
緩和措施
建議的緩和措施是將伺服器端應用程式升級至 Tls1.0、Tls1.1 或 Tls 1.2。 如果這並不可行,或是用戶端應用程式已中斷,則可使用 AppContext 類別搭配下列兩種方式之一,停用這項功能:
以程式化方式使用程式碼片段,如下所示:
const string DisableCachingName = @"TestSwitch.LocalAppContext.DisableCaching"; const string DontEnableSchUseStrongCryptoName = @"Switch.System.Net.DontEnableSchUseStrongCrypto"; AppContext.SetSwitch(DisableCachingName, true); AppContext.SetSwitch(DontEnableSchUseStrongCryptoName, true);Const DisableCachingName As String = "TestSwitch.LocalAppContext.DisableCaching" Const DontEnableSchUseStrongCryptoName As String = "Switch.System.Net.DontEnableSchUseStrongCrypto" AppContext.SetSwitch(DisableCachingName, True) AppContext.SetSwitch(DontEnableSchUseStrongCryptoName, True)ServicePointManager因為物件只會初始化一次,因此定義這些相容性設定必須是應用程式做的第一件事。
將下列這一行新增至 <app.config 檔案的執行時間> 區段:
<AppContextSwitchOverrides value="Switch.System.Net.DontEnableSchUseStrongCrypto=true"/>
不過請注意,不建議選擇不執行預設行為,因為這樣會降低應用程式的安全性。