解决小程序要求的TLS版本必须大于等于1.2问题

最近在做一个微信小程序项目,先先后发现苹果机使用小程序报错,,看错误信息很明显是网络问题。


image.png

最后开启调试模式下,发现是SSL问题。


image.png

经过网上这么一查,发现是服务器配置问题,找到几个解决方案,大同小异,但是有些方案我这边是有问题的,因此我把成功的方案在总结一下:

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


    image.png

我的服务器是windows2008R2,在配置SSL做小程序开发时候提示小程序的TLS版本必须大于等于1.2。
请先确认系统支持TLS1.2以后,进行一下操作:(如不支持请升级系统到支持版本)

  1. 备份原注册文件HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols的值


    image.png

3.执行reg文件即可将其中的数据导入到注册表当中
通常Windows服务器默认没有TLS1.2,此时需要自己安装,安装很简单,复制下面代码,保存到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
  1. 检查注册表是否注册成功
    成功后,如图


    image.png

5.验证tls问题是否已经解决
下面网址用来检查tls问题

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

image.png

提示:注册文件执行后需要重启服务器才能生效。

参考网址:

https://www.cnblogs.com/puzi0315/p/9217038.html

你可能感兴趣的:(解决小程序要求的TLS版本必须大于等于1.2问题)