您的位置:首页 > 理论基础 > 计算机网络

记录一次升级https走过的坑

2017-05-12 14:48 225 查看
记录一次升级https过程中走过的坑
curl: (51) SSL: certificate subject name 'mp3.xxx.com' does not match target host name 'static.xxx.com'

升级 http://mp3.xxx.com http://static.xxx.com
https://mp3.xxx.com https://static.xxx.com
因在一台服务器上配置的两个域名都解析到本机,配置完后,发现页面的静态文件都无法加载
于是F12看了下,发现加载的证书和浏览器地址栏的域名竟然不一致。请求的static这个域名,确加
载的mp3的证书。用curl也报错,不能正常返回200,纳闷了!




[root@web ~]# curl -I https://static.xxx.com/static/lib/less.min.js curl: (51) SSL: certificate subject name 'mp3.xxx.com' does not match target host name 'static.xxx.com'




后来求助伟大的谷歌,发现原来是nginx的TLS SNI support功能没开,SNI (服务器名字指示)不开启的话,一个IP只支持一个SSL证书,不支持多个证书,而服务器是yum安装的nginx,默认TLS SNI support是关闭的,重新编译nginx并指定openssl库后,TLS SNI support 开启了,访问就正常了
yum update openssl

cd openssl-1.0.0d
./config --prefix=/usr/local/openssl
make && make install
./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_ssl_module --with-http_gzip_static_module --with-http_gunzip_module --with-http_stub_status_module --with-http_addition_module --with-http_realip_module --with-openssl=/usr/local/src/openssl-1.0.0d

另外的一个问题是这种情况下用curl测试时,状态码不能正常返回200,开启LS SNI support后也依然报错,不能正常返回200。看curl官网有人反馈,这好像是curl版本7.15.5的BUG,用比7.15.5新的curl 7.19.7版本测试就正常。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  https ssl SNI