[轉帖]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;
相關文章
相關標籤/搜索