终于解决了Let’s Encrypt的OCSP装订问题(再也不用担心Let’s Encrypt证书引起的错误问题了),该问题之前描述过,由于Let’s Encrypt证书的OCSP服务器被墙,导致OCSP无法装订,以至于火狐(firefox)浏览器报错Secure Connection Failed:
The OCSP server suggests trying again later. Error code: SEC_ERROR_OCSP_TRY_SERVER_LATER。
解决方案,就是找一个国内服务器可以访问的OCSP ip,在服务器上设置hosts,让服务器可以连接到Let’s Encrypt的OCSP服务器:http://ocsp.int-x3.letsencrypt.org
终于,今天我在Holmesian Blog的文章中,找到了这个ip:23.32.3.72。但是,我最后处理OCSP装订问题时,跟这位站长的解决方案稍微有那么点差别,所以分享出来供各位参考。
首先,服务器ssh输入如下命令,修改hosts文件:
vi /etc/hosts
摁下i键,进入插入模式,再最后一行插入如下代码:
23.32.3.72 ocsp.int-x3.letsencrypt.org
摁下esc按键,输入:wq。退出并保存文件即可(注意是:wq,共三个字符)
:wq
接着服务器输入如下命令,看是否正常连接到OCSP服务器:(主要查看是否返回23.32.3.72这个ip,并且可以ping通)
ping ocsp.int-x3.letsencrypt.org
然后,我们直接输入如下命令,续期Let’s Encrypt证书(为的是刷新下OCSP装订状态):
certbot renew
等待证书续期完成(一般还没到有效期,所以肯定续期失败,但会刷新OCSP状态),得到如下反馈:
Upgrading certbot-auto 1.8.0 to 1.9.0...
Replacing certbot-auto...
Creating virtual environment...
Installing Python packages...
Installation succeeded.
Saving debug log to /var/log/letsencrypt/letsencrypt.log
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing /etc/letsencrypt/renewal/iymark.com.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cert not yet due for renewal
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
The following certs are not due for renewal yet:
/etc/letsencrypt/live/iymark.com/fullchain.pem expires on 2020-12-13 (skipped)
No renewals were attempted.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
我们打开/var/log/letsencrypt/letsencrypt.log这个日志文件,查看OCSP是否响应成功:
vi /var/log/letsencrypt/letsencrypt.log
然后,摁下:q退出日志文件。
接着我们输入如下命令,查看OCSP是否装订成功:
openssl s_client -connect iymark.com:443 -status -tlsextdebug < /dev/null 2>&1 | grep -i "OCSP response"
成功会返回如下内容:
OCSP response:
OCSP Response Data:
OCSP Response Status: successful (0x0)
Response Type: Basic OCSP Response
失败会返回如下内容:
OCSP response:
OCSP Response Data:
OCSP Response Status: trylater (0x3)
最后,我们再到myssl.com上检查下证书状态就可以了(可能有时间等问题,所以需要等那么一会:我也是第一次没装订成功,过了一会再检查证书,就装订成功了)
到此,总算解决了Let’s Encrypt的证书问题!
最后需要注意的是,OCSP一直都是装订正常状态(只是因为服务器无法连接到OCSP服务器,导致检测到OCSP装订有问题)。
当然,OCSP会有个响应有效时间,一般为一周。如果到时候,OCSP又失效了,可以再次通过证书续期命令来刷新OCSP:
certbot renew
至于一周过后,还要不要再更新OCSP,还不清楚。不过,以我的感觉判断,应该不会了。下面是查询OCSP完整信息的代码:
[root@iZwz98biiph4vhee88vxj8Z ~]# openssl s_client -connect iymark.com:443 -status 2>/dev/null | grep -A 17 'OCSP response:'
OCSP response:
======================================
OCSP Response Data:
OCSP Response Status: successful (0x0)
Response Type: Basic OCSP Response
Version: 1 (0x0)
Responder Id: C = US, O = Let's Encrypt, CN = Let's Encrypt Authority X3
Produced At: Nov 1 06:11:00 2020 GMT
Responses:
Certificate ID:
Hash Algorithm: sha1
Issuer Name Hash: ****************
Issuer Key Hash: ****************
Serial Number: ****************
Cert Status: good
This Update: Nov 1 06:00:00 2020 GMT
Next Update: Nov 8 06:00:00 2020 GMT
我再到火狐浏览器上,开启OCSP查询后,发现网站终于正常了。通过证书检测、OCSP状态查看、火狐浏览器检测,可以认为Let’s Encrypt证书OCSP装订这个问题完美的解决了。
原创文章,作者:古哥,转载需经过作者授权同意,并附上原文链接:https://iymark.com/articles/654.html