一年一度的startssl证书更新时间到了。去年的帖子在这里。 今年本来应该正常更新startssl证书的,但是,遇到一个大坑,就是有些浏览器不支持startssl了,主要是firefox,chrom
一年一度的startssl证书更新时间到了。去年的帖子在这里。
今年本来应该正常更新startssl证书的,但是,遇到一个大坑,就是有些浏览器不支持startssl了,主要是firefox,chrome是可以的,iPad上的Safari也可以,iphone的Safari有问题,mac上的Safari也没问题。
官方说法是:
.1. Mozilla and Google decided to distrust all StartCom root certificates as of 21st of October, this situation will have an impact in the upcoming release of Firefox and Chrome in January. Apple's decision announced on Nov 30th of distrusting all StartCom root certificates as of 1st of December will have an impact in their upcoming security update.
2. Any subscribers that paid the validation fee after Oct. 21st can get full refund by request.
3. StartCom will provide an interim solution soon and will replace all the issued certificates with issuance date on or after Oct 21st in case of requested. Meanwhile StartCom is updating all systems and will generate new root CAs as requested by Mozilla to regain the trust in these browsers.
用谷歌翻译了一下就是:
.1.Mozilla和Google决定不信任所有StartCom根证书,截至10月21日,这种情况将对即将发布的Firefox和Chrome在1月的影响。苹果公司决定于11月30日宣布,不再信任12月1日的所有StartCom根证书,这将对他们即将到来的安全更新产生影响。
2.任何在10月21日之后支付验证费的用户可以根据请求获得全额退款。
3.StartCom将尽快提供一个临时解决方案,并将在10月21日或之后的发布日期替换所有已颁发的证书。同时,StartCom正在更新所有系统,并将根据Mozilla的要求生成新的根CA,以重新获得对这些浏览器的信任。
看时间点,应该是2016年发的通知。不过有一点,新证书的有效时间是3年。没办法,这个证书就是为了提供给内部的plist下载的, iOS要求用https协议,所以对于我这边来说就没法用了。
只能再次在网上找其他解决方案,很顺利找到了Let's Encrypt。网上有很多篇帖子,不同的做法,我是参照这篇帖子做的,因为看到其他帖子说python2.7以下可能会有问题,直接把python升级到2.7,过程略过。
好像这个网址访问会失效,内容整理如下:
#下载acme-tiny的源码sudo git clone https://github.com/diafygi/acme-tiny.git#创建Let's Encrypt私钥openssl genrsa 4096 > account.key#创建CSR(Certificate Signing Request,证书签名请求) 文件,填自己要申请的域名openssl genrsa 4096 > domain.key openssl req -new -sha256 -key domain.key -subj "/" -reqexts SAN -config <(cat /etc/ssl/openssl.cnf <(printf "[SAN]/nsubjectAltName=DNS:yoursite.com,DNS:www.yoursite.com")) > domain.csr#证明你拥有该域名acme-tiny脚本会生成验证文件并写入到你指定的目录下,然后通过 ".well-known/acme-challenge/" 这个URL来访问到验证文件. 注意: Let's Encrypt 会对你的服务器做一次http请求来进行验证,因此你需要保证80端口能够访问.server { listen 80; server_name yoursite.com www.yoursite.com; if ( $request_uri !~ "/.well-known/acme-challenge/*" ) { # 让 Let's Encrypt 成功访问到验证文件不受 301 影响 return 301 https://yoursite.com$request_uri; # 注意进行301重定向到https,否则通过http仍能访问你的站点 } location /.well-known/acme-challenge/ { alias /var/www/challenges/; try_files $uri =404; } #...你的其他配置}#获取签名证书sudo chmod +x acme_tiny.py python acme_tiny.py --account-key ./account.key --csr ./domain.csr --acme-dir /var/www/challenges/ > ./signed.crt#安装证书wget -O - https://letsencrypt.org/certs/lets-encrypt-x3-cross-signed.pem > intermediate.pem cat signed.crt intermediate.pem > chained.pemserver { listen 443; server_name yoursite.com www.yoursite.com; ssl on; ssl_certificate /path/to/chained.pem; ssl_certificate_key /path/to/domain.key; ssl_session_timeout 5m; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA; ssl_session_cache shared:SSL:50m; ssl_prefer_server_ciphers on; #...你的其他配置}
需要注意的是,如果没有强制要求所有的链接都用https,就屏蔽这段,git上的说明也没有这段nginx配置。
if ( $request_uri !~ "/.well-known/acme-challenge/*" ) { # 让 Let's Encrypt 成功访问到验证文件不受 301 影响 return 301 https://yoursite.com$request_uri; # 注意进行301重定向到https,否则通过http仍能访问你的站点 }
很顺利就配置完成通过测试了。这里是有nginx配合,tomcat里面就不用配置https。如果没有nginx呢?那就是直接支持.well-known/acme-challenge/* 这个请求,可以参考这篇帖子,里面用的是Spring MVC的框架,直接加一段代码就可以了。因为考虑到要加代码,还是直接用nginx,挺简单的。
因为Let's Encrypt的证书有效时间只有90天,所以要设置自动更新,脚本帖子里已经有了,明天我再试试效果。→测试自动更新证书没问题,已经正常运行了。
后续漏洞检查的时候提示公共密钥过弱,解决办法就是:
openssl dhparam -out dhparams.pem 2048
然后在nginx的https里面加上ssl_dhparam /xxx/dhparams.pem 就可以了
完。