語言

風險降低:TLS 通訊協定

從 .NET Framework 4.6 開始,System.Net.ServicePointManager 和 System.Net.Security.SslStream 類別不再支援 SSL 3.0 協定或 RC4 密碼。

影響

這項變更會影響:

緩和措施

建議的緩解方法是升級伺服器端應用程式以支援現代 TLS 配置。 如果這不可行,或是客戶端應用程式有問題, 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"/>  
    

不過請注意,不建議選擇不執行預設行為,因為這樣會降低應用程式的安全性。

另請參閱