转帖 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) |(SecurityProtocolType) | (SecurityProtocolType);

最新文章

  1. 通过JSch编写上传、下载文件
  2. c++中endl的函义
  3. .NET程序的编译和运行
  4. 双数组Trie树 (Double-array Trie) 及其应用
  5. git https连接方式,记住密码
  6. Week6(10月14日)
  7. 在DLL中导出另一静态库中的函数
  8. 模板引擎(smarty)知识点总结
  9. 痞子衡嵌入式:ARM Cortex-M内核MCU开发那些事 - 索引
  10. IntelliJ IDEA 的下载和安装
  11. 虚拟机的ip地址为什么会发生变化
  12. 【转】让浏览器格式化显示JSON数据之chrome jsonView插件安装
  13. Linux搭建bugfree
  14. android 生成、pull解析xml文件
  15. Twitter开源的Heron快速安装部署教程
  16. jquery 简单的别踩白块小游戏
  17. c++11 输出时间
  18. webpack添加热更新
  19. Spring Boot 揭秘与实战(二) 数据存储篇 - MyBatis整合
  20. 22.Windows及linux下gerapy使用

热门文章

  1. 深度学习与计算机视觉(11)_基于deep learning的快速图像检索系统
  2. 5249: [2018多省省队联测]IIIDX
  3. CSS3新增特性详解(一)
  4. 180815-Spring之RestTemplate中级使用篇
  5. 如何在忘记mysql的登录密码时更改mysql登录的密码(window及linux)
  6. RenderSprite小记
  7. 求二维数组最大子数组的和。郭林林&胡潇丹
  8. Docker部署Golang
  9. 马赛克是否无法逆转?Python简单消除,看片无忧!
  10. oracle和mysql在sql中生成uuid的方法