如何解决:对应的服务器 tls 为 tls 1.0,小程序要求的TLS版本必须大于等于1.2问题

本文介绍了解决微信小程序开发中TLS版本低于1.2的问题。通过编辑注册表禁用旧版协议并启用TLS 1.2, 重启服务器后可使Windows 2008 R2系统支持新版TLS。


微信小程序  TLS 版本必须大于等于1.2问题解决

此问题最近在微信小程序开发中,比较常见。

在解决这个问题之前,我们需要了解一下,当前的系统环境是否支持TLS1.2以上,可以参考一下表格:

image.png

请先确认系统支持TLS1.2以后,进行一下操作:(如不支持请升级系统到支持版本)

windows2008R2在配置SSL做小程序开发时候提示小程序的TLS版本必须大于等于1.2。

解决方法:

请先备份导出HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols的值。如图:

image.png

将以下代码,保存到一个txt文件,然后修改后缀.reg,双击执行即可,完成这一步后,重启服务器。

Windows Registry Editor Version 5.00

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

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\Multi-Protocol Unified Hello]

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\Multi-Protocol Unified Hello\Client]
"Enabled"=dword:00000000
"DisabledByDefault"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\Multi-Protocol Unified Hello\Server]
"Enabled"=dword:00000000
"DisabledByDefault"=dword:00000001

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

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

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

[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]
"Enabled"=dword:00000000
"DisabledByDefault"=dword:00000001

[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]
"Enabled"=dword:00000000
"DisabledByDefault"=dword:00000001

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

[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]
"Enabled"=dword:00000001
"DisabledByDefault"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Server]
"Enabled"=dword:00000001
"DisabledByDefault"=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]
"Enabled"=dword:00000001
"DisabledByDefault"=dword:00000000


http://www.landui.com/help/show-6155.html


下面网址用来检查tls问题

https://www.ssllabs.com/ssltest/analyze.html


参考网址:

安卓真机调试request:fail ssl hand shake error 报错,苹果没有问题。


为了解决微信小程序要求 TLS 版本不低于 1.2问题,需从服务器配置和系统支持两个方面入手。以下是具体操作方法: ### 服务器端配置 1. **检查服务器 TLS 支持版本**: - 如果服务器运行在 Windows 上,可以通过注册表编辑器查看当前启用的 TLS 版本。进入以下路径: ``` HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\ ``` 检查是否存在并启用了 TLS 1.2 相关的项 [^1]。 2. **启用 TLS 1.2**: - 在上述注册表路径中,如果没有 TLS 1.2 的项,可以右键点击 `Protocols`,选择“新建” -> “项”,然后创建名为 `TLS 1.2` 的项。 - 确保在 `TLS 1.2` 下包含 `Client` 和 `Server` 子项,以启用客户端和服务器端的 TLS 1.2 支持 [^2]。 3. **禁用不安全的旧版本 TLS**: - 如果服务器启用了 TLS 1.0TLS 1.1,建议将其禁用以提高安全性。进入对应版本的注册表项(如 `TLS 1.1`),在 `Client` 和 `Server` 子项下创建一个名为 `Enabled` 的 DWORD 值,并将其设置为 `0` [^3]。 4. **重启服务器**: - 修改注册表后,需要重启服务器以确保配置生效。 ### 客户端支持 - 微信小程序本身依赖于客户端设备的 TLS 支持情况。例如,iOS 9 及以上版本默认支持 TLS 1.2,但部分 Android 设备可能需要更新系统或使用 HTTPS 库来支持更高版本TLS。 - 对于微信小程序开发者,需要确保服务器地址在小程序后台配置为 HTTPS,并且服务器证书有效且由可信的 CA 签发。 ### 验证配置 - 使用在线工具(如 [SSL Labs](https://www.ssllabs.com/))测试服务器TLS 配置,确保 TLS 1.2 已启用且评分良好。 - 在微信小程序中,可以使用 `wx.request` 发起 HTTPS 请求,观察是否仍然报错。如果成功请求,说明 TLS 配置已正确生效。 ### 示例代码:检查服务器 TLS 支持情况 以下是一个简单的 Python 脚本,用于检查远程服务器TLS 支持情况: ```python import ssl import socket def check_tls_support(host, port=443): context = ssl.create_default_context() try: with socket.create_connection((host, port)) as sock: with context.wrap_socket(sock, server_hostname=host) as ssock: print(f"Connected with TLS version: {ssock.version()}") except Exception as e: print(f"Error: {e}") # 示例:检查 example.com 的 TLS 支持 check_tls_support("example.com") ```
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值