简体   繁体   English

客户端和服务器无法通信,因为它们没有共同的算法 - ASP.NET C# IIS TLS 1.0 / 1.1 / 1.2 - Win32

[英]The client and server cannot communicate, because they do not possess a common algorithm - ASP.NET C# IIS TLS 1.0 / 1.1 / 1.2 - Win32Exception

I have an issue with a C# PayTrace Gateway.我对 C# PayTrace 网关有疑问。 The below code was working fine until yesterday when I believe they turned off SSL3 due to the Poodle Exploit.下面的代码一直运行良好,直到昨天我相信他们由于 Poodle Exploit 而关闭了 SSL3。 When running the code below we got the following message.运行下面的代码时,我们收到以下消息。 The remote server has forcefully closed the connection.远程服务器已强制关闭连接。 After doing some research on the problem we determined that because our IIS Server 7.5 was configured to still use SSL3, C# defaulted to SSL3, which PayTrace would forcibly close the connection.在对问题进行了一些研究后,我们确定由于我们的 IIS Server 7.5 配置为仍然使用 SSL3,C# 默认为 SSL3,PayTrace 将强制关闭连接。 We then removed SSL3 from the server.然后我们从服务器中删除了 SSL3。 Which then lead to the following error:然后导致以下错误:

The client and server cannot communicate, because they do not possess a common algorithm.客户端和服务器无法通信,因为它们没有共同的算法。

My guess is that there are additional SSL algorithm we need to install on the server now that SSL 3 is removed.我的猜测是,在删除 SSL 3 后,我们需要在服务器上安装额外的 SSL 算法。 Our IT staff claims that TLS 1.1 and TLS 1.2 are working and that ASP.NET should be now defaulting to those.我们的 IT 人员声称 TLS 1.1 和 TLS 1.2 正在运行,并且 ASP.NET 现在应该默认使用这些。 But I feel like there still must be something else we need to install on the server, I have no knowledge of SSL Algorithms so I have no idea where to begin.但我觉得我们还必须在服务器上安装其他东西,我不知道 SSL 算法所以我不知道从哪里开始。

var postUrl = new StringBuilder();

//Initialize url with configuration and parameter values...
postUrl.AppendFormat("UN~{0}|", this.MerchantLoginID);
postUrl.AppendFormat("PSWD~{0}|", this.MerchantTransactionKey);
postUrl.Append("TERMS~Y|METHOD~ProcessTranx|TRANXTYPE~Sale|"); 
postUrl.AppendFormat("CC~{0}|", cardNumber);
postUrl.AppendFormat("EXPMNTH~{0}|", expirationMonth.PadLeft(2, '0'));
postUrl.AppendFormat("EXPYR~{0}|", expirationYear);
postUrl.AppendFormat("AMOUNT~{0}|", transactionAmount);
postUrl.AppendFormat("BADDRESS~{0}|", this.AddressLine1);
postUrl.AppendFormat("BADDRESS2~{0}|", this.AddressLine2);
postUrl.AppendFormat("BCITY~{0}|", this.City);
postUrl.AppendFormat("BSTATE~{0}|", this.State);
postUrl.AppendFormat("BZIP~{0}|", this.Zip);
postUrl.AppendFormat("SADDRESS~{0}|", this.AddressLine1);
postUrl.AppendFormat("SADDRESS2~{0}|", this.AddressLine2);
postUrl.AppendFormat("SCITY~{0}|", this.City);
postUrl.AppendFormat("SSTATE~{0}|", this.State);
postUrl.AppendFormat("SZIP~{0}|", this.Zip);
if (!String.IsNullOrEmpty(this.Country))
{
    postUrl.AppendFormat("BCOUNTRY~{0}|", this.Country);
}
if (!String.IsNullOrEmpty(this.Description))
{
    postUrl.AppendFormat("DESCRIPTION~{0}|", this.Description);
}
if (!String.IsNullOrEmpty(this.InvoiceNumber))
{
    postUrl.AppendFormat("INVOICE~{0}|", this.InvoiceNumber);
}
if (this.IsTestMode)
{
    postUrl.AppendFormat("TEST~Y|");
}

//postUrl.Append();

WebClient wClient = new WebClient();
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;
String sRequest = "PARMLIST=" + Url.Encode(postUrl.ToString());
wClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
string sResponse = "";
sResponse = wClient.UploadString(PayTraceUrl, sRequest);

Also, just an FYI, this issue is also happening when we connect to First Data E4 gateway so it's not just a PayTrace thing.此外,仅供参考,当我们连接到 First Data E4 网关时也会发生此问题,因此这不仅仅是 PayTrace 的事情。 My guess is that as more gateways turn off access to SSL3 we'll continue to run into issues with other gateways until this can be resolved on the server.我的猜测是,随着更多网关关闭对 SSL3 的访问,我们将继续遇到其他网关的问题,直到可以在服务器上解决此问题。 Also, I did find a few suggestions online, some suggested placing the following code right before making the outbound request:另外,我确实在网上找到了一些建议,一些建议在发出出站请求之前放置以下代码:

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;

Unfortunately that did not work either, same error.不幸的是,这也不起作用,同样的错误。 Which is why I'm thinking something additional needs to be installed on the IIS7.5 server.这就是为什么我认为需要在 IIS7.5 服务器上安装一些额外的东西。 I'm just not sure what.我只是不确定是什么。

There are several other posts about this now and they all point to enabling TLS 1.2.现在还有其他几篇关于此的帖子,它们都指向启用 TLS 1.2。 Anything less is unsafe.少一点都是不安全的。

You can do this in .NET 3.5 with a patch.您可以使用补丁在 .NET 3.5 中执行此操作。
You can do this in .NET 4.0 and 4.5 with a single line of code您可以在 .NET 4.0 和 4.5 中使用一行代码执行此操作

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; // .NET 4.5
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072; // .NET 4.0

In .NET 4.6, it automatically uses TLS 1.2.在 .NET 4.6 中,它自动使用 TLS 1.2。

See here for more details: .NET support for TLS .有关更多详细信息,请参见此处: .NET support for TLS

在我的情况下,即使项目的目标框架是 4.7.1,我仍然得到同样的错误,解决方案是将 system.web 下的 web.config 中的 httpRuntime 更改为 4.7.1!

In a previous answer, it was suggested to use this line of code for .Net 4.5:在先前的答案中,建议将这行代码用于 .Net 4.5:

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; // .NET 4.5

I would encourage you to OR that value in to whatever the existing values are like this:我鼓励您将该值与现有的值进行或,如下所示:

ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12; // .NET 4.5

If you look at the list of values, you notice that they are a power of two.如果您查看值列表,您会注意到它们是 2 的幂。 This way, in the future when things shift to TLS 2.0 for example, your code will still work.这样,将来当事情转移到 TLS 2.0 时,您的代码仍然可以工作。

There are two possible scenario, in my case I used 2nd point.有两种可能的情况,就我而言,我使用了第二点。

  1. If you are facing this issue in production environment and you can easily deploy new code to the production then you can use of below solution.如果您在生产环境中遇到此问题,并且可以轻松地将新代码部署到生产环境中,那么您可以使用以下解决方案。

    You can add below line of code before making api call,您可以在进行 api 调用之前添加以下代码行,

    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; // .NET 4.5

  2. If you cannot deploy new code and you want to resolve with the same code which is present in the production, then this issue can be done by changing some configuration setting file.如果您无法部署新代码并且您想使用生产中存在的相同代码解决此问题,则可以通过更改一些配置设置文件来解决此问题。 You can add either of one in your config file.您可以在配置文件中添加其中任何一个。

<runtime>
    <AppContextSwitchOverrides value="Switch.System.Net.DontEnableSchUseStrongCrypto=false"/>
  </runtime>

or或者

<runtime>
  <AppContextSwitchOverrides value="Switch.System.Net.DontEnableSystemDefaultTlsVersions=false"/>
</runtime>

This was resolved.这已解决。 It turns out our IT Staff was correct.事实证明,我们的 IT 人员是正确的。 Both TLS 1.1 and TLS 1.2 were installed on the server. TLS 1.1 和 TLS 1.2 都安装在服务器上。 However, the issue was that our sites are running as ASP.NET 4.0 and you have to have ASP.NET 4.5 to run TLS 1.1 or TLS 1.2.但是,问题是我们的站点以 ASP.NET 4.0 运行,您必须拥有 ASP.NET 4.5 才能运行 TLS 1.1 或 TLS 1.2。 So, to resolve the issue, our IT Staff had to re-enable TLS 1.0 to allow a connection with PayTrace.因此,为了解决这个问题,我们的 IT 人员必须重新启用 TLS 1.0 以允许与 PayTrace 建立连接。

So in short, the error message, "the client and server cannot communicate, because they do not possess a common algorithm", was caused because there was no SSL Protocol available on the server to communicate with PayTrace's servers.所以简而言之,错误消息“客户端和服务器无法通信,因为它们没有共同的算法”,是因为服务器上没有可用的 SSL 协议来与 PayTrace 的服务器通信。

UPDATE: Please do not enable TLS 1.0 on your servers, this was a temporary fix and is not longer applicable since there are now better work-arounds that ensure strong security practices.更新:请不要在您的服务器上启用 TLS 1.0,这是一个临时修复,不再适用,因为现在有更好的解决方法可以确保强大的安全实践。 Please see accepted answer for a solution.请参阅已接受的答案以获取解决方案。 FYI, I'm going to keep this answer on the site as it provides information on what the problem was, please do not down-vote.仅供参考,我将在网站上保留此答案,因为它提供了有关问题所在的信息,请不要投反对票。

Enabling TLS 1.0 solved our issues as well (after disabling SSL v3).启用 TLS 1.0 也解决了我们的问题(在禁用 SSL v3 之后)。 (Server 2012 R2 with ASP.net 4.0 website processing against PPI pay services). (Server 2012 R2 与 ASP.net 4.0 网站处理针对 PPI 付费服务)。 This is the RegEdit script I used to set everything the way I wanted.这是我用来按我想要的方式设置所有内容的 RegEdit 脚本。 We only disabled SSL v3 for the Client and not the server as doing that broke other things that we were not ready to deal with yet.我们只为客户端而不是服务器禁用 SSL v3,因为这样做会破坏我们尚未准备好处理的其他事情。 After we upgrade the site to .Net 4.5.2 then we will disable TLS 1.0 again.在我们将站点升级到 .Net 4.5.2 之后,我们将再次禁用 TLS 1.0。

This script enables all protocols, Server and Client except for SSL v3 for the Client.此脚本为客户端启用除 SSL v3 之外的所有协议、服务器和客户端。

Be sure to backup your registry!请务必备份您的注册表!

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 3.0\Client]
"Enabled"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 3.0\Server]
"Enabled"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Client]
"Enabled"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Client]
"DisabledByDefault"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Server]
"Enabled"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Server]
"DisabledByDefault"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1\Client]
"Enabled"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1\Client]
"DisabledByDefault"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1\Server]
"Enabled"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1\Server]
"DisabledByDefault"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client]
"Enabled"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client]
"DisabledByDefault"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Server]
"Enabled"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Server]
"DisabledByDefault"=dword:00000000

My app is running in .net 4.7.2.我的应用程序在 .net 4.7.2 中运行。 Simplest solution was to add this to the config:最简单的解决方案是将其添加到配置中:

  <system.web>
    <httpRuntime targetFramework="4.7.2"/>
  </system.web>

In my case I solved the problem by enabling the last TLS version in the .Net Framework as explained in this article:就我而言,我通过在 .Net Framework 中启用最后一个 TLS 版本来解决问题,如本文所述:

https://docs.microsoft.com/dotnet/framework/network-programming/tls https://docs.microsoft.com/dotnet/framework/network-programming/tls

set these registry keys:设置这些注册表项:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319] "SystemDefaultTlsVersions"=dword:00000001
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319] "SystemDefaultTlsVersions"=dword:00000001
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319] "SchUseStrongCrypto"=dword:00000001
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319] " SchUseStrongCrypto"=dword:00000001

There are a couple of things that you need to check related to this.您需要检查与此相关的几件事。

Whenever there is an error like this thrown related to making a secure connection, try running a script like the one below in Powershell with the name of the machine or the uri (like "www.google.com") to get results back for each of the different protocol types:每当出现与建立安全连接相关的此类错误时,请尝试在 Powershell 中使用机器名称或 uri(如“www.google.com”)运行如下脚本,以获取每个脚本的结果不同的协议类型:

 function Test-SocketSslProtocols {
    
    [CmdletBinding()] 
    param(
        [Parameter(Mandatory=$true)][string]$ComputerName,
        [int]$Port = 443,
        [string[]]$ProtocolNames = $null
        )

    #set results list    
    $ProtocolStatusObjArr = [System.Collections.ArrayList]@()


    if($ProtocolNames -eq $null){

        #if parameter $ProtocolNames empty get system list
        $ProtocolNames = [System.Security.Authentication.SslProtocols] | Get-Member -Static -MemberType Property | Where-Object { $_.Name -notin @("Default", "None") } | ForEach-Object { $_.Name }

    }
 
    foreach($ProtocolName in $ProtocolNames){

        #create and connect socket
        #use default port 443 unless defined otherwise
        #if the port specified is not listening it will throw in error
        #ensure listening port is a tls exposed port
        $Socket = New-Object System.Net.Sockets.Socket([System.Net.Sockets.SocketType]::Stream, [System.Net.Sockets.ProtocolType]::Tcp)
        $Socket.Connect($ComputerName, $Port)

        #initialize default obj
        $ProtocolStatusObj = [PSCustomObject]@{
            Computer = $ComputerName
            Port = $Port 
            ProtocolName = $ProtocolName
            IsActive = $false
            KeySize = $null
            SignatureAlgorithm = $null
            Certificate = $null
        }

        try {

            #create netstream
            $NetStream = New-Object System.Net.Sockets.NetworkStream($Socket, $true)

            #wrap stream in security sslstream
            $SslStream = New-Object System.Net.Security.SslStream($NetStream, $true)
            $SslStream.AuthenticateAsClient($ComputerName, $null, $ProtocolName, $false)
         
            $RemoteCertificate = [System.Security.Cryptography.X509Certificates.X509Certificate2]$SslStream.RemoteCertificate
            $ProtocolStatusObj.IsActive = $true
            $ProtocolStatusObj.KeySize = $RemoteCertificate.PublicKey.Key.KeySize
            $ProtocolStatusObj.SignatureAlgorithm = $RemoteCertificate.SignatureAlgorithm.FriendlyName
            $ProtocolStatusObj.Certificate = $RemoteCertificate

        } 
        catch  {

            $ProtocolStatusObj.IsActive = $false
            Write-Error "Failure to connect to machine $ComputerName using protocol: $ProtocolName."
            Write-Error $_

        }   
        finally {
            
            $SslStream.Close()
        
        }

        [void]$ProtocolStatusObjArr.Add($ProtocolStatusObj)

    }

    Write-Output $ProtocolStatusObjArr

}

Test-SocketSslProtocols -ComputerName "www.google.com"

It will try to establish socket connections and return complete objects for each attempt and successful connection.它将尝试建立套接字连接并为每次尝试和成功连接返回完整的对象。

After seeing what returns, check your computer registry via regedit (put "regedit" in run or look up "Registry Editor"), place看到返回的内容后,通过 regedit 检查您的计算机注册表(将“regedit”放入运行或查找“注册表编辑器”),放置

Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL

in the filepath and ensure that you have the appropriate TLS Protocol enabled for whatever server you're trying to connect to (from the results you had returned from the scripts).在文件路径中,并确保为您尝试连接的任何服务器启用了适当的 TLS 协议(根据您从脚本返回的结果)。 Adjust as necessary and then reset your computer (this is required).根据需要进行调整,然后重置您的计算机(这是必需的)。 Try connecting with the powershell script again and see what results you get back.再次尝试连接 powershell 脚本,看看你得到了什么结果。 If still unsuccessful, ensure that the algorithms, hashes, and ciphers that need to be enabled are narrowing down what needs to be enabled (IISCrypto is a good application for this and is available for free. It will give you a real time view of what is enabled or disabled in your SChannel registry where all these things are located).如果仍然不成功,请确保需要启用的算法、哈希和密码正在缩小需要启用的范围(IISCrypto 是一个很好的应用程序,并且可以免费使用。它会给你一个实时视图在所有这些东西所在的 SChannel 注册表中启用或禁用)。

Also keep in mind the Windows version, DotNet version, and updates you have currently installed because despite a lot of TLS options being enabled by default in Windows 10, previous versions required patches to enable the option.还要记住您当前安装的 Windows 版本、DotNet 版本和更新,因为尽管在 Windows 10 中默认启用了许多 TLS 选项,但以前的版本需要补丁才能启用该选项。

One last thing: TLS is a TWO-WAY street (keep this in mind) with the idea being that the server's having things available is just as important as the client.最后一件事:TLS 是一条双向街道(请记住这一点),其理念是服务器拥有可用的东西与客户端一样重要。 If the server only offers to connect via TLS 1.2 using certain algorithms then no client will be able to connect with anything else.如果服务器只提供使用某些算法通过 TLS 1.2 进行连接,那么客户端将无法连接其他任何东西。 Also, if the client won't connect with anything else other than a certain protocol or ciphersuite the connection won't work.此外,如果客户端不与某个协议或密码套件以外的任何其他东西连接,则连接将无法工作。 Browsers are also something that need to be taken into account with this because of their forcing errors on HTTP2 for anything done with less than TLS 1.2 DESPITE there NOT actually being an error (they throw it to try and get people to upgrade but the registry settings do exist to modify this behavior).浏览器也需要考虑到这一点,因为它们在 HTTP2 上强制错误对于使用低于 TLS 1.2 完成的任何事情,尽管实际上没有错误(他们抛出它试图让人们升级但注册表设置确实存在修改此行为)。

After messing with this for days, my final fix for our issues required two things;在搞砸了几天之后,我对我们问题的最终解决需要两件事;

1) We added this line of code to all of our .Net libraries that make out bound api calls to other vendors that had also disabled their SSL v3. 1) 我们将这行代码添加到我们所有的 .Net 库中,这些库向也禁用了 SSL v3 的其他供应商发出绑定 api 调用。

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls; // (.Net 4 and below)

2) This is the final and FULL registry changes you will need when you are running ASP.Net 4.0 sites and will need to be slightly changed after you upgrade to ASP.Net 4.5. 2) 这是您在运行 ASP.Net 4.0 站点时需要的最终和完整的注册表更改,升级到 ASP.Net 4.5 后需要稍作更改。

After we rebooted the servers - all problems went away after this.在我们重新启动服务器后 - 此后所有问题都消失了。

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 2.0\Client]
"DisabledByDefault"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 2.0\Client]
"Enabled"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 2.0\Server]
"DisabledByDefault"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 2.0\Server]
"Enabled"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 3.0\Client]
"DisabledByDefault"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 3.0\Client]
"Enabled"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 3.0\Server]
"DisabledByDefault"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 3.0\Server]
"Enabled"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Client]
"Enabled"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Client]
"DisabledByDefault"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Server]
"Enabled"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Server]
"DisabledByDefault"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1\Client]
"Enabled"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1\Client]
"DisabledByDefault"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1\Server]
"Enabled"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1\Server]
"DisabledByDefault"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client]
"Enabled"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client]
"DisabledByDefault"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Server]
"Enabled"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Server]
"DisabledByDefault"=dword:00000000

I fixed this error by upgrading the app from .Net Framework 4.5 to 4.6.2.我通过将应用程序从 .Net Framework 4.5 升级到 4.6.2 来修复此错误。

TLS-1.2 was correctly installed on the server, and older versions like TLS-1.1 were disabled. TLS-1.2 已正确安装在服务器上,并且像 TLS-1.1 这样的旧版本已被禁用。 However, .Net 4.5 does not support TLS-1.2.但是,.Net 4.5 不支持 TLS-1.2。

In previous answers a few registry keys that might not exist are missed.在以前的答案中,一些可能不存在的注册表项被遗漏了。 They are SchUseStrongCrypto that must exist to allow to TLS protocols work properly.它们是 SchUseStrongCrypto,必须存在才能让 TLS 协议正常工作。

After the registry keys have been imported to registry it should not be required to make changes in code like将注册表项导入注册表后,不应要求对代码进行更改,例如

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;

Below there are all registry keys and values that are needed for x64 windows OS.下面是 x64 Windows 操作系统所需的所有注册表项和值。 If you have 32bit OS (x86) just remove the last 2 lines.如果您有 32 位操作系统 (x86),只需删除最后两行。 TLS 1.0 will be disabled by the registry script.注册表脚本将禁用 TLS 1.0。 Restarting OS is required.需要重新启动操作系统。

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols]

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 2.0]

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 2.0\Client]
"DisabledByDefault"=dword:00000001
"enabled"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 2.0\server]
"disabledbydefault"=dword:00000001
"enabled"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\ssl 3.0]

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\ssl 3.0\client]
"disabledbydefault"=dword:00000001
"enabled"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\ssl 3.0\server]
"disabledbydefault"=dword:00000001
"enabled"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\tls 1.0]

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\tls 1.0\client]
"disabledbydefault"=dword:00000001
"enabled"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\tls 1.0\server]
"disabledbydefault"=dword:00000001
"enabled"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\tls 1.1]

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\tls 1.1\client]
"disabledbydefault"=dword:00000000
"enabled"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\tls 1.1\server]
"disabledbydefault"=dword:00000000
"enabled"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\tls 1.2]

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\tls 1.2\client]
"disabledbydefault"=dword:00000000
"enabled"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\tls 1.2\server]
"disabledbydefault"=dword:00000000
"enabled"=dword:00000001

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319]
"SchUseStrongCrypto"=dword:00000001

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319]
"SchUseStrongCrypto"=dword:00000001

I had the same error when connecting from Windows Server 2012. I resolved by changing the TLS and SSL settings using the IIS Crypto executable.从 Windows Server 2012 连接时,我遇到了同样的错误。我通过使用 IIS Crypto 可执行文件更改 TLS 和 SSL 设置解决了问题。 Specifically, I disabled Server Protocols SSL 3.0 and TLS 1.0.具体来说,我禁用了服务器协议 SSL 3.0 和 TLS 1.0。 I also disabled Client Protocol SSL 3.0 (I believe this is what did the trick).我还禁用了客户端协议 SSL 3.0(我相信这就是诀窍)。 I used a server that was working correctly as the basis for determining the ideal settings.我使用了一个正常工作的服务器作为确定理想设置的基础。 Screenshot - IIS Crypto Settings屏幕截图 - IIS 加密设置

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 SoapHttpClientProtocol和TLS 1.2 - 客户端和服务器无法通信,因为它们没有通用的算法 - SoapHttpClientProtocol and TLS 1.2 - The client and server cannot communicate, because they do not possess a common algorithm HTTP Web 请求 TLS 1.3 C# .NET 核心 3.1 异常“客户端和服务器无法通信,因为它们不具备通用算法。” - HTTP Web Request TLS 1.3 with C# .NET Core 3.1 exception "The client and server cannot communicate, because they do not possess a common algorithm." ASP.NET 4.5客户端和服务器无法通信,因为它们不具有通用算法 - ASP.NET 4.5 The client and server cannot communicate, because they do not possess a common algorithm C# 客户端和服务器无法通信,因为它们没有通用的算法 - C# The client and server cannot communicate, because they do not possess a common algorithm 客户端和服务器无法通信,因为它们没有通用的算法C#SslStream - The client and server cannot communicate, because they do not possess a common algorithm, C# SslStream TLS 1. 2 客户端和服务器无法通信,因为它们没有通用算法 - TLS 1. 2 The client and server cannot communicate, because they do not possess a common algorithm 无法创建SSL / TLS安全通道。客户端和服务器无法通信,因为它们没有通用算法 - Could not create SSL/TLS secure channel. The client and server cannot communicate, because they do not possess a common algorithm 客户端和服务器无法通信,因为它们没有通用的 WCF 算法 - The client and server cannot communicate, because they do not possess a common algorithm WCF 客户端和服务器无法通信,因为它们在Windows Server 2008 Web上不具有通用算法 - The client and server cannot communicate, because they do not possess a common algorithm on Windows Server 2008 Web SSLStream.AuthenticateAsServer “客户端和服务器无法通信,因为它们没有通用算法” - SSLStream.AuthenticateAsServer “The client and server cannot communicate, because they do not possess a common algorithm”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM