如何开启Windows Server 2012的TLS1.2?
美国、香港服务器
如何开启Windows Server 2012的TLS1.2?
11-04 来源:
## 一、一键 PowerShell 脚本(推荐,一次性全部配置)
# ========== SCHANNEL 系统TLS 1.2 开启(客户端+服务端) ==========
New-Item "HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client" -Force | Out-Null
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client" -Name "Enabled" -Value 1 -PropertyType DWord -Force
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client" -Name "DisabledByDefault" -Value 0 -PropertyType DWord -Force
New-Item "HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Server" -Force | Out-Null
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Server" -Name "Enabled" -Value 1 -PropertyType DWord -Force
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Server" -Name "DisabledByDefault" -Value 0 -PropertyType DWord -Force
# ========== WinHTTP 默认启用TLS1.1+TLS1.2(宝塔核心!)0xA00=2560 ==========
New-Item "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\WinHttp" -Force | Out-Null
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\WinHttp" -Name DefaultSecureProtocols -Value 0xA00 -PropertyType DWord -Force
New-Item "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Internet Settings\WinHttp" -Force | Out-Null
New-ItemProperty -Path "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Internet Settings\WinHttp" -Name DefaultSecureProtocols -Value 0xA00 -PropertyType DWord -Force
# ========== .NET程序启用强加密(宝塔、各类.NET工具) ==========
# .NET 4.x
New-Item "HKLM:\SOFTWARE\Microsoft\.NETFramework\v4.0.30319" -Force | Out-Null
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\.NETFramework\v4.0.30319" -Name SchUseStrongCrypto -Value 1 -PropertyType DWord -Force
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\.NETFramework\v4.0.30319" -Name SystemDefaultTlsVersions -Value 1 -PropertyType DWord -Force
New-Item "HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319" -Force | Out-Null
New-ItemProperty -Path "HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319" -Name SchUseStrongCrypto -Value 1 -PropertyType DWord -Force
New-ItemProperty -Path "HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319" -Name SystemDefaultTlsVersions -Value 1 -PropertyType DWord -Force
Write-Host " TLS1.2注册表配置完成,请重启服务器!"
1. 复制全部代码,右键开始菜单 → **Windows PowerShell (管理员)**
2. 粘贴回车执行
3. **重启服务器**(必须重启,注册表才全部生效)
## 二、前置补丁(原版 2012 必看,R2 不用)
原版 Windows Server 2012 想要让 `DefaultSecureProtocols` 生效,**必须先安装微软补丁 KB3140245**,不装这个补丁,上面 WinHTTP 注册表是无效的,宝塔依旧下载失败Microsoft ...。
2012 R2 自带支持,不需要 KB3140245。
## 三、reg 注册表文件
新建 `TLS12.reg`,下面内容,双击导入:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client]
"Enabled"=dword:00000001
"DisabledByDefault"=dword:00000000
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Server]
"Enabled"=dword:00000001
"DisabledByDefault"=dword:00000000
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\WinHttp]
"DefaultSecureProtocols"=dword:00000a00
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Internet Settings\WinHttp]
"DefaultSecureProtocols"=dword:00000a00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319]
"SchUseStrongCrypto"=dword:00000001
"SystemDefaultTlsVersions"=dword:00000001
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319]
"SchUseStrongCrypto"=dword:00000001
"SystemDefaultTlsVersions"=dword:00000001
## 四、验证 TLS1.2 是否生效(重启后测试)
管理员 PowerShell 执行,测试 WinHTTP 访问 HTTPS(测试 TLS1.2)
Invoke-WebRequest -Uri "https://www.cloudflare.com/ips-v4" -UseBasicParsing
能正常返回内容 = WinHTTP TLS1.2 正常
报错、连接失败 = 补丁没装 / 注册表没生效
三二互联专业提供香港VPS,美国VPS主机,香港云服务器租用等业务香港美国到大陆CN2 GIA速度最快