如何开启系统TLS1.2?
美国、香港服务器
如何开启系统TLS1.2?
10-23 来源:
## 、安装系统补丁 KB3140245
1. 在本地电脑下载补丁包,上传到服务器
2. 在服务器运行安装,完成后**先重启一次服务器**
## 二、方法 1:PowerShell 一键写入注册表(推荐,复制直接执行)
1. 右键开始菜单,**以管理员身份打开 PowerShell**
2. 复制下面全部代码,粘贴回车执行:
# 创建TLS1.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 "DisabledByDefault" -Value 0 -PropertyType DWord -Force
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client" -Name "Enabled" -Value 1 -PropertyType DWord -Force
# 创建TLS1.2服务端注册表项
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 "DisabledByDefault" -Value 0 -PropertyType DWord -Force
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Server" -Name "Enabled" -Value 1 -PropertyType DWord -Force
# 设置WinHTTP默认使用TLS1.2(宝塔下载必须这一条!)
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 0x00000800 -PropertyType DWord -Force
3. **重启服务器**,注册表配置才生效
## 方法 2:手动注册表编辑器(regedit)
1. Win+R,输入 `regedit` 打开注册表
2. 定位路径:
`HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\`
3. 在`Protocols`下面新建项:`TLS 1.2`,里面再新建两项:`Client` 和 `Server`
4. 在 `Client` 里面新建 2 个 **DWORD (32 位) 值**:
- `DisabledByDefault` 值填 `0`
- `Enabled` 值填 `1`
5. `Server` 项同样新建这两个 DWORD,值一样
6. 定位:`HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\WinHttp`
新建`DefaultSecureProtocols`,Dword 值填 `2048`(十六进制 0x800)
7. 重启服务器
## 三、浏览器 Internet 选项(辅助,可选)
1. 控制面板 → Internet 选项 → 高级
2. 下拉,勾选 **使用 TLS1.2**,取消 TLS1.0、TLS1.1
3. 应用保存
## 四、验证 TLS1.2 是否开启成功
管理员 PowerShell 执行:
[Net.ServicePointManager]::SecurityProtocol
如果返回包含 `Tls12`,代表成功。
## 五、针对宝塔安装的补充说明
2008R2 默认 WinHTTP 不支持 TLS1.2,宝塔下载 Python 包是底层 WinHTTP 请求,**只勾 IE 浏览器 TLS 是没用的,必须改 WinHTTP 注册表项**。
如果补丁 KB3140245 无法安装,说明系统缺少前置 SP1 补丁包,这种情况就算改注册表也无法启用 TLS1.2,建议直接离线放 python.7z 包绕开下载。
## 六、导入 reg 文件一键方案(备用)
新建文本文档,复制下面内容,另存为 `EnableTLS12.reg`,双击导入注册表
```
Windows Registry Editor Version 5.00
[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\Windows\CurrentVersion\Internet Settings\WinHttp]
"DefaultSecureProtocols"=dword:00000800
导入完成后重启服务器。
完成 TLS1.2 开启后,再去重新运行宝塔安装程序。如果依旧 Python 下载失败,直接用离线方案上传 python.7z。
三二互联专业提供香港VPS,美国VPS主机,香港云服务器租用等业务香港美国到大陆CN2 GIA速度最快