Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 如何在Windows Server 2019上运行的ASP.NET MVC应用程序中启用TLS 1.0和TLS 1.1?_Asp.net Mvc_Ssl_Iis_Azure Cloud Services_Windows Server 2019 - Fatal编程技术网

Asp.net mvc 如何在Windows Server 2019上运行的ASP.NET MVC应用程序中启用TLS 1.0和TLS 1.1?

Asp.net mvc 如何在Windows Server 2019上运行的ASP.NET MVC应用程序中启用TLS 1.0和TLS 1.1?,asp.net-mvc,ssl,iis,azure-cloud-services,windows-server-2019,Asp.net Mvc,Ssl,Iis,Azure Cloud Services,Windows Server 2019,我有一个ASP.NET MVC web服务,托管在Microsoft Azure云服务中(作为web角色),当前的目标是.NET Framework 4.5.2,并配置为在Windows Server 2012上运行。我需要将其迁移到.NET Framework 4.7.2和Windows Server 2019。一切都很好,除了 Windows Server 2012的配置使IIS默认允许TLS 1.0、TLS 1.1和TLS 1.2,但Windows Server 2019将IIS配置为仅允

我有一个ASP.NET MVC web服务,托管在Microsoft Azure云服务中(作为web角色),当前的目标是.NET Framework 4.5.2,并配置为在Windows Server 2012上运行。我需要将其迁移到.NET Framework 4.7.2和Windows Server 2019。一切都很好,除了

Windows Server 2012的配置使IIS默认允许TLS 1.0、TLS 1.1和TLS 1.2,但Windows Server 2019将IIS配置为仅允许TLS 1.2。这可能会中断某些客户端,因此我希望在Windows 2019中临时启用TLS 1.0和1.1,然后与客户端对话并禁用除TLS 1.2以外的所有客户端

我发现这表明我需要更改注册表项

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Server]
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Client]
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1\Server]
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1\Client]

"Enabled"=dword:ffffffff
"DisabledByDefault"=dword:00000000
在那里。(我也尝试了
dword:00000001
而不是
dword:ffffff
-没有区别)我将此作为启动任务,以便将必要的更改导入注册表

这没用。我用来检查可用的TLS模式。它说只有TLS 1.2在变更前后都是允许的。它正确地显示了1.0、1.1和1.2可用于Windows Server 2012


如何启用TLS 1.0和1.1?

您可以使用下面的Powershell脚本来启用TLS 1.0和1.1:

    [CmdletBinding()]
Param(
[Parameter(Mandatory=$True)]
[ValidateSet("SSL30","TLS10","TLS11","TLS12")]
[string]$Proto,
[ValidateSet("Client","Server")]
[string]$Target,
[Parameter(Mandatory=$True)]
[ValidateSet("Enable","Disable")]
$Action)

Function CheckKey{
param(
[string]$Proto
)
$RegKey = $null

switch ($Proto){
   SSL30 {$RegKey = "HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 3.0"}
   TLS10 {$RegKey = "HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0"}
   TLS11 {$RegKey = "HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1"}
   TLS12 {$RegKey = "HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2"}
   default{"Not supported protocol. Possible values: SSL30, TLS10, TLS11, TLS12"
            exit}
  }
return $Regkey
}

$RegKey = CheckKey -Proto $Proto
[string[]]$TargetKey = $null
if(!($Target)){
  Write-Host "Setting up both Client and Server protocols"
  $TargetKey = $(Join-Path $RegKey "Client").ToString()
  $TargetKey += $(Join-Path $RegKey "Server").ToString()
  if(!(Test-path -Path $TargetKey[0])){
       New-Item $TargetKey[0] -Force
   }
  if(!(Test-path -Path $TargetKey[1])){
       New-Item $TargetKey[1] -Force
    }
  } 
else{
  Write-Host "Setting up $Target protocols"
  $TargetKey = $(Join-Path $RegKey $Target).ToString()
  if(!(Test-path -Path $(Join-Path $RegKey $Target))){
       New-Item $TargetKey -Force   
    }
 }

Function SetProto{
param(

[string[]]$TargetKey,
[string]$Action
)

foreach($key in  $TargetKey){
   try{
       Get-ItemProperty -Path $key -Name "Enabled" -ErrorAction Stop | Out-Null
       if($Action -eq "Disable"){
          Write-Host "`t`Updating $key"                     
          Set-ItemProperty -Path $key -Name "Enabled" -Value 0 -Type "DWord"
         }
       else{
          Write-Host "`t`Updating $key"
          Set-ItemProperty -Path $key -Name "Enabled" -Value 1 -Type "DWord"
         }
      }Catch [System.Management.Automation.PSArgumentException]{
          if($Action -eq "Disable"){
             Write-Host "`t`Creating $key"
             New-ItemProperty -Path $key -Name "Enabled" -Value 0 -PropertyType "DWord"
            }
          else{
             Write-Host "`t`Creating $key"
             New-ItemProperty -Path $key -Name "Enabled" -Value 1 -PropertyType "DWord"
           }
       }

try{
     Get-ItemProperty -Path $key -Name "DisabledByDefault" -ErrorAction Stop | Out-Null
     if($Action -eq "Disable"){
        Write-Host "`t`Updating $key"
        Set-ItemProperty -Path $key -Name "DisabledByDefault" -Value 1 -Type "DWord"
       }
     else{
        Write-Host "`t`Updating $key"
        Set-ItemProperty -Path $key -Name "DisabledByDefault" -Value 0 -Type "DWord"
        }
     }Catch [System.Management.Automation.PSArgumentException]{
        if($Action -eq "Disable"){
           Write-Host "`t`Creating $key"
           New-ItemProperty -Path $key -Name "DisabledByDefault" -Value 1 -PropertyType "DWord"
          }
        else{
           Write-Host "`t`Creating $key"
           New-ItemProperty -Path $key -Name "DisabledByDefault" -Value 0 -PropertyType "DWord"
          }
     }
  }
}

SetProto -TargetKey $TargetKey -Action $Action

Write-Host "The operation completed successfully, reboot is required" -ForegroundColor Green
使用网络监视工具检查正在使用的协议站点。


启用或禁用协议后,不要忘记重新启动计算机。

为TLS 1.0/1.1添加密码套件。完整脚本(以管理员身份运行):

$suites=@(
“TLS_ECDHE_ECDSA_与_AES_128_GCM_SHA256”,
“TLS_ECDHE_ECDSA_与_AES_256_GCM_SHA384”,
“TLS_ECDHE_RSA_与_AES_128_GCM_SHA256”,
“TLS_ECDHE_RSA_与_AES_256_GCM_SHA384”,
'TLS_ECDHE_ECDSA_与_AES_128_CBC_SHA256',
“TLS_ECDHE_ECDSA_与_AES_256_CBC_SHA384”,
“TLS_ECDHE_RSA_与_AES_128_CBC_SHA256”,
“TLS_ECDHE_RSA_与_AES_256_CBC_SHA384”,
“TLS_ECDHE_ECDSA_与_AES_256_CBC_SHA”,
“TLS_ECDHE_ECDSA_与_AES_128_CBC_SHA”,
“TLS_ECDHE_RSA_与_AES_256_CBC_SHA”,
“TLS_ECDHE_RSA_与_AES_128_CBC_SHA”,
“TLS_RSA_和_AES_256_GCM_SHA384”,
“TLS_RSA_和_AES_128_GCM_SHA256”,
“TLS_RSA_与_AES_256_CBC_SHA256”,
“TLS_RSA_与_AES_128_CBC_SHA256”,
“TLS_RSA_与_AES_256_CBC_SHA”,
‘TLS_RSA_与_AES_128_CBC_SHA’
)
$registry=@(
@{Path='HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Server';Name='DisabledByDefault';Type='DWord';Value=0},
@{Path='HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Server';Name='Enabled';Type='DWord';Value=1},
@{Path='HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1\Server';Name='DisabledByDefault';Type='DWord';Value=0},
@{Path='HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1\Server';Name='Enabled';Type='DWord';Value=1},
@{Path='HKLM:\SOFTWARE\Policies\Microsoft\Cryptography\Configuration\SSL\00012';Name='Functions';Type='String';Value='suites-Join','}
)
$reboot=$null
foreach($注册表中的行){
if(-Not(测试路径$row.Path)){
新项目-路径$row.Path-强制|输出空值
}
试一试{
$val=Get ItemPropertyValue-Path$row.Path-Name$row.Name
}抓住{
$val=$null
}
如果($val-ne$row.Value){
$reboot=$true
Set-ItemProperty-Path$row.Path-Name$row.Name-Type$row.Type-Value$row.Value-Force
写入主机“$($row.Path)!$($row.Name)=$($row.Value)”
}
}
如果($reboot-eq$true){
写主机“现在重新启动…”
shutdown.exe/r/t 0/c“重新启动以使注册表更改生效”/f/d p:2:4
}

我尝试手动应用这些更改(并重新启动角色实例)。无效。能否共享注册表设置值和网络监视器测试结果?是否解决了此问题?我们的问题与你面临的完全相同。任何帮助都会很好。@StefanHa还没有。我们提交了一份支持单,现在我们正在等待文档更新,这有望解决问题。到目前为止,我们只是继续在Windows Server 2012上运行我们的服务。与此同时,我找到了一个解决方案。我们在开发服务器上使用了这个工具。这启用了TLS 1.0和1.1。此工具添加了旧TLS所需的一些密码套件。我们正在向ServiceConfiguration中添加一个批处理文件cscfg now,它通过启动标签启用正确的注册表设置。希望自2018年6月起不再支持此helpsBtw TLS 1.0,因此您不必关心它。TLS1.1可能在明年被弃用。@Thomas Whatever。我们仍然不能突然放弃它们,因为这可能会破坏一些客户。这有记录在案吗?提供列表。您可以在WS2016上运行,也可以查看指向WS2016服务器的SSLLAB。有密码套件和TLS版本的详细信息。现在这里有文档记录(对不支持TLS 1.2的应用程序进行故障排除)是的,需要添加某些密码。要使更改生效,还需要重新启动。这对于云服务web角色来说是非常不幸的。