[转帖]TLS 版本问题

转帖 From 

https://www.cnblogs.com/xjnotxj/p/7252043.html

一、环境:

CentOS 6.8
nginx 1.6.0
php 7.0.10

二、背景

最近开发一个小程序,而小程序对后台接口服务器的要求是:

1、请求域名在request合法域名
2、基于 https 协议
3、TLS 版本 1.2+

1、2 两条都满足了,但是第三条亟待解决,导致小程序调用接口时报错:

三、正文

(1)为什么要满足 TLS 版本 1.2+ ?

2017年1月1日起,苹果强制所有 app 满足 HTTPS,即 iOS9 推出的 App Transport Security (ATS) 特性。

访问 https://www.qcloud.com/product/ssl#userDefined10 ,
输入域名,检查您的 iOS app 是否满足 ATS 特性:

报错了,提示不支持 TLS1.2。

(2)如何满足 TLS 版本 1.2+ ?

1、openSSL 版本 1.0.1+

查看 openSSL 版本:

openssl version -a

2、nginx 版本为 0.7.65,0.8.19 及更高版本

查看 nginx 版本:

nginx -V

结果是,我的版本都符合要求。

(3)nginx 配置 TLS1.2

本人申请的是腾讯云的安全证书,官方有提供 nginx 如何配置的文档:
https://www.qcloud.com/document/product/400/6973#1.nginx-.E8.AF.81.E4.B9.A6.E9.85.8D.E7.BD.AE

配置 nginx.conf 支持 TLS1.2 的方法如下(看 ssl_protocols 参数):

server {
        listen 443;
        server_name www.domain.com; #填写绑定证书的域名 ssl on; ssl_certificate 1_www.domain.com_bundle.crt; ssl_certificate_key 2_www.domain.com.key; ssl_session_timeout 5m; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #按照这个协议配置 ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;#按照这个套件配置 ssl_prefer_server_ciphers on; location / { root html; #站点目录 index index.html index.htm; } }

四、遇到的问题

按照上文一切都做完之后,发现还是不行。

折腾好久之后。

发现,原来是 nginx 之前有配另一个 https 的 server,关于
ssl_protocols 的参数值为:

  ssl_protocols  SSLv2 SSLv3 TLSv1;

里面根本没有包含 TLSv1.2!从而影响了我们这个 server!

所以把改成:

  ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

再测试:

完美。

 
以及启用的方法 更高级别安全性的方法
The DEFAULT System.Net.ServicePointManager.SecurityProtocol in both .NET 4.0/4.5 is:

 SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls.

.NET 4.0 supports up to TLS 1.0 while .NET 4.5 supports up to TLS 1.2

However, an application targeting .NET 4.0 can still support up to TLS 1.2 if .NET 4.5 is installed in the same environment. .NET 4.5 installs on top of .NET 4.0, replacing System.dll.

I've verified this by observing the correct security protocol set in traffic with fiddler4 and by manually setting the enumerated values in a .NET 4.0 project:

ServicePointManager.SecurityProtocol = (SecurityProtocolType)192 |(SecurityProtocolType)768 | (SecurityProtocolType)3072;

 

转载于:https://www.cnblogs.com/jinanxiaolaohu/p/9677762.html

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值