[转帖]TLS 版本问题

转帖 From 

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

1、环境:

CentOS 6.8
nginx 1.6.0
php 7.0.10css

2、背景

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

一、请求域名在request合法域名
二、基于 https 协议
三、TLS 版本 1.2+nginx

一、2 两条都知足了,可是第三条亟待解决,致使小程序调用接口时报错:小程序

3、正文

(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。markdown

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

一、openSSL 版本 1.0.1+session

查看 openSSL 版本:app

openssl version -a

二、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; } }

4、遇到的问题

按照上文一切都作完以后,发现仍是不行。

折腾很久以后。

发现,原来是 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;
相关文章
相关标签/搜索