TLS 1.2 not negotiated in .NET 4.7 without explicit ServicePointManager.SecurityProtocol call

后端 未结 5 1512
长情又很酷
长情又很酷 2020-12-04 15:51

I need to upgrade a .NET application to support a call to an API on a website that only supports TLS 1.2. From what I read, if the application is targeting 4.6 or higher the

5条回答
  •  旧巷少年郎
    2020-12-04 16:04

    Starting with apps that target the .NET Framework 4.7, the default value of the ServicePointManager.SecurityProtocol property is SecurityProtocolType.SystemDefault.

    This change allows .NET Framework networking APIs based on SslStream (such as FTP, HTTPS, and SMTP) to inherit the default security protocols from the operating system instead of using hard-coded values defined by the .NET Framework.

    That's the reason of the new behaviour you experienced and the need of the new configuration:

    
        
    
    

    See here and here

    Update (useful info)

    Keep in mind, best security practices suggest to update your IIS configuration disabling, time by time, old protocols and ciphers key (e.g. TLS 1.0, 1.1). See Setup Microsoft Windows or IIS for SSL Perfect Forward Secrecy and TLS 1.2 for very interesting info.

    If you follow this practice, you don't need to set the configuration above (as MS suggests), because your Win server / IIS is already well configured.

    Of course, this is possible only if you have access to the server with proper grants.

提交回复
热议问题