iOS9下基于ATS对HTTPS要求的 tls 1.2环境之nginx环境配置

本文介绍了在iOS9引入的App Transport Security (ATS) 要求下,如何配置nginx以支持TLS 1.2进行HTTPS通信。针对使用centos、php和nginx的服务器环境,提供了nginx配置示例、关键软件版本信息、安装步骤以及测试方法,并分享了在升级nginx和openssl过程中遇到的问题和解决方案。
摘要由CSDN通过智能技术生成
一、需求
iOS9中新增App Transport Security(简称ATS)特性, 主要使到原来请求的时候用到的HTTP,都转向TLS1.2协议进行传输。这也意味着所有的HTTP协议都强制使用了HTTPS协议进行传输。因此移动api需要配置为https并且要支持tls 1.2

二、项目情况
服务器端:公司的服务器的采用的操作系统是centos,开发语言php,web容器采用的nginx。
客户端:ios android
客户端和服务的通信采用http和json
app内的部分功能通过webbiew加载h5完成。

三、最终配置成功
nginx.conf中的相关配置如下:
server
{
server_name mobileapi.xx.com;
index index.html index.htm index.php default.html default.htm default.php;
root /home/wwwroot/mobileapi.xx.com/web;


listen 443 ssl;
ssl on;
ssl_certificate /home/wwwroot/ssl.xx.com/xx.crt;
ssl_certificate_key /home/wwwroot/ssl.xx.com/xx.key;
ssl_session_timeout 5m;

ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers AESGCM:ALL:!DH:!EXPORT:!RC4:+HIGH:!MEDIUM:!LOW:!aNULL:!eNULL;
ssl_prefer_server_ciphers on;


include none.conf;
location ~ .*\.(php|php5)?$
{
try_files $uri =404;
#fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_pass unix:/dev/shm/php-cgi.sock;
fastcgi_index index.php;
include fcgi.conf;
}

location /{
if (!-e $request_filename){
rewrite ^/(.*) /index.php last;
}
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}

location ~ .*\.(js|css)?$
{
expires 12h;
}

access_log off;
}


四、关键软件的版本
nginx 1.11.7
openssl 1.0.1e-fips
contos 6.3

五、nginx和openssl安装
openssl安装yum install openssl
从官网下载nginx 1.11.7
nginx安装命令:./configure --prefix=/usr/local/nginx1_11_7 --with-http_ssl_module


六、测试方法
nscurl --ats-diagnostics https://mobileapi.xx.com
如果全部pass 证明配置成功

七、遇到的坑
nginx当时是1.4.4版本太低,不支持tls 1.2
openssl版本太低,当时是0.9.8e
CentOS 如果是5.x的,升级openssl要手工,没法用yum


七、参考资料

https://my.oschina.net/vimfung/blog/494687
https://zhidao.baidu.com/question/1114939951869020059.html
http://blog.sina.com.cn/s/blog_4e11d20b0102vmne.html
http://bguncle.blog.51cto.com/3184079/1392870/
http://www.cnblogs.com/hitwtx/archive/2012/02/13/2349742.html
https://my.oschina.net/u/1423896/blog/267511
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值