设为首页 加入收藏

TOP

HTTPS 站点的性能优化(二)
2019-09-17 17:45:34 】 浏览:53
Tags:HTTPS 站点 性能 优化
p 全称在线证书状态检查协议 (rfc6960),用来向 CA 站点查询证书状态,比如是否撤销。通常情况下,浏览器使用 OCSP 协议发起查询请求,CA 返回证书状态内容,然后浏览器接受证书是否可信的状态。 将证书保存下来,浏览器请求时候直接通过自己的服务器发送回去,防止验证服务器出问题,还能加快访问速度。

查看OSCP验证服务器地址:

1
openssl x509 -in 1_test.qupeiyin.net_bundle.crt  -text

在输出的文字中找到 OCSP - URI: ,后面的 URL 就是 OSCP 的验证服务器地址。

请求 OSCP 证书

1
2
3
4
openssl ocsp -noverify \
-issuer /certificate-path/trustchain.crt \
-cert /certificate-path/trustchain.crt \

不出意外会收到如下的结果

1
2
3
trustchain.crt: good       
     This Update: Oct 18 17:59:10 2014 GMT       
     Next Update: Oct 18 23:59:10 2014 GMT

如果出现 403 错误,那就需要在 Header 请求头加上域名参数如 -header “HOST” “ocsp2.globalsign.com” ,没问题后就可以直接保存下来证书文件,完整的命令如下:

1
2
3
4
openssl
ocsp -noverify  -issuer 1_root_bundle.crt
-cert 1_root_bundle.crt -url http://ocsp1.wosign.com/ca6/server1  -header "HOST"
"ocsp1.wosign.com" -text -respout ./stapling_file.ocsp

将保存下来的 stapling_file.ocsp 证书添加到 nginx 的配置中,如下,Nginx 中配置变成了这样子:

1
2
3
4
ssl_stapling on;
ssl_stapling_verify on;
ssl_stapling_file /stapling_file.ocsp;
ssl_trusted_certificate /certificate-path/trustchain.crt;

这样子重启 Nginx 后就会生效,可以使用下面的命令测试生效结果:

1
echo QUIT | openssl s_client -connect blog.alphatr.com:443 -status 2> /dev/null | grep -A 17 'OCSP response:' | grep -B 17 'Next Update'

看到 OCSP Response Status: successful 这样的字样就是成功了。

ocsp证书有效期很短,大概不到一个月,所以过段时间要更新 ocsp 证书,不然还是会验证失败。需要用脚本定时更新OCSP证书。

总结:(全部优化参数)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
ssl on;
ssl_certificate /data/www/ssl/ssl.crt;
ssl_certificate_key /data/www/ssl/ssl.key;
ssl_trusted_certificate /data/www/ssl/trustchain.crt;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES256-SHA384:AES256-SHA256:RC4:HIGH:!MD5:!aNULL:!eNULL:!NULL:!DH:!EDH:!AESGCM;
ssl_prefer_server_ciphers on;
ssl_stapling on;
ssl_stapling_verify on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
add_header Strict-Transport-Security "max-age=31536000";
resolver 223.5.5.5 223.6.6.6 valid=300s;
resolver_timeout 10s;
error_page 497 https://$host$request_uri;

参数详解:

ssl on  开启SSL

ssl_certificate  对应单张证书

ssl_certificate_key  对应私钥

ssl_trusted_certificate  对应信任链(即Startcom SSL或者Positive SSL中需要附加到单张证书后面的那两张证书,可以独立出来)

ssl_protocols  支持的SSL协议标准(nginx默认参数为:ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;)

ssl_ciphers  (nginx默认参数为:ssl_ciphers HIGH:!aNULL:!MD5;)

ssl_prefer_server_ciphers On;  指定服务器密码算法在优先于客户端密码算法时,使用SSLv3和TLS协议。

error_page 497 https://$host$request_uri;  通过497错误将http转跳到https

首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇搭建springboot项目 下一篇java ssm 后台框架平台 项目源码 ..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目