The request was aborted: Could not create SSL/TLS secure channel

后端 未结 30 1795
遇见更好的自我
遇见更好的自我 2020-11-22 01:21

We are unable to connect to an HTTPS server using WebRequest because of this error message:

The request was aborted: Could not create SSL/TLS secur

30条回答
  •  不思量自难忘°
    2020-11-22 01:44

    One of the biggest causes of this issue is the active .NET Framework version. The .NET framework runtime version affects which security protocols are enabled by default.

    There doesn't seem to be any authoritative documentation on how it specifically works in different versions, but it seems the defaults are determined more or less as follows:

    • .NET Framework 4.5 and earlier - SSL 3.0, TLS 1.0
    • .NET Framework 4.6.x - TLS 1.0, 1.1, 1.2, 1.3
    • .NET Framework 4.7+ - System (OS) Defaults

    (For the older versions, your mileage may vary somewhat based on which .NET runtimes are installed on the system. For example, there could be a situation where you are using a very old framework and TLS 1.0 is not supported, or using 4.6.x and TLS 1.3 is not supported)

    Microsoft's documentation strongly advises using 4.7+ and the system defaults:

    We recommend that you:

    • Target .NET Framework 4.7 or later versions on your apps. Target .NET Framework 4.7.1 or later versions on your WCF apps.
    • Do not specify the TLS version. Configure your code to let the OS decide on the TLS version.
    • Perform a thorough code audit to verify you're not specifying a TLS or SSL version.

    For ASP.NET sites: check the targetFramework version in your element, as this (when present) determines which runtime is actually used by your site:

    
    

    Better:

    
    

提交回复
热议问题