得到两个文件,并双击打开他们
然后到keychain里导出.cer文件,后面会用到
把刚才的cer证书文件导入到项目中:
AFNetworking3.x配置ATS
NSData * certData =[NSData dataWithContentsOfFile:cerPath];
NSSet * certSet = [[NSSet alloc] initWithObjects:certData, nil];
AFSecurityPolicy *securityPolicy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeCertificate];
// 是否允许,NO-- 不允许无效的证书
[securityPolicy setAllowInvalidCertificates:YES];
// 设置证书
[securityPolicy setPinnedCertificates:certSet];
manager.securityPolicy = securityPolicy;
检查https网站是否通过TLSV1.2,通过以下命令:
nscurl --ats-diagnostics --verbose https://secure.getgaoding.com
Nginx配置,开启TLSv1.2 修改nginx下的配置文件conf/nginx.conf
server {
listen 443;
server_name secure.getgaoding.com;
access_log /get/log/nginx/secure/secure.access.log main;
ssl on;
ssl_certificate /usr/local/nginx/secure.getgaoding.com_combined.crt;
ssl_certificate_key /usr/local/nginx/secure.getgaoding.com.key;
ssl_session_timeout 5m;
ssl_protocols SSLv2 SSLv3 TLSv1 TLSv1.2 TLSv1.1;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location ~* ^/user/* {
proxy_pass http://userapi;
}
location ~* ^/sender/* {
proxy_pass http://send;
}
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
} }