# Letsencrypt certbot命令的默认操作使得网站在Android端报证书错误的问题 [[https://letsencrypt.org/|Letsencrypt]]乃HTTPS时代的一大良心产品,其良心不仅在于免费提供**不用自己安装根证书**的HTTPS签名,更在于为各主流Linux发行版提供了软件包,理论上几个命令就可以完成网站签名,并且自动修改`nginx`配置文件。 不过,我前段时间在树莓派上用`Letsencrypt`提供的`certbot`工具对本站进行签名时,发现了这工具的默认行为有点怪:签名成功后,一共提供了四个签名文件,并且还提供了README文件: This directory contains your keys and certificates. `privkey.pem` : the private key for your certificate. `fullchain.pem`: the certificate file used in most server software. `chain.pem` : used for OCSP stapling in Nginx >=1.3.7. `cert.pem` : will break many server configurations, and should not be used without reading further documentation (see link below). WARNING: DO NOT MOVE OR RENAME THESE FILES! Certbot expects these files to remain in this location in order to function properly! We recommend not moving these files. For more information, see the Certbot User Guide at https://certbot.eff.org/docs/using.html#where-are-my-certificates. 奇怪之处在于,`certbot`它自己明明说了`cert.pem`这个文件“will break many server configurations”,但它在默认设置下偏偏就把这个文件用到了`nginx`配置文件的`ssl_certificate`字段中。后果倒是不严重:由于PC浏览器多数已经内置了对于`Letsencrypt`证书的信任,所以访问没啥问题。但移动的浏览器尤其是`Android`,访问这网站时就会弹警告说证书不对,一些客户端类工具如[[https://joplinapp.org/|Joplin]]则直接报错(还报的是”网络连接失败“这种不明所以的错)。 Android端报错的原因是[[https://hooyes.net/p/letsencrypt|证书链不对]],简单来说就是`cert.pem`这个文件缺了一些内容。更正方法是在`nginx`配置文件中,将`ssl_certificate`字段指向的文件地址,由`cert.pem`修改到同目录下的`fullchain.pem`. #ssl_certificate /etc/letsencrypt/live/www.tiger2doudou.com/cert.pem; #上面一行修改为 ssl_certificate /etc/letsencrypt/live/www.tiger2doudou.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/www.tiger2doudou.com/privkey.pem; ...... 然后重启`nginx`,Android端应该就不报错了。 [[https://hooyes.net/p/letsencrypt|前面链接里]]教了可以通过手动操作补全,但`Letsencrypt`证书需要每90天更新,每次操作就太麻烦了。 [[:Website:QNAP:QNAP_Joplin_deploy|PS:这就是中间证书的问题,TrustAsia的证书也出了一次这问题,点此进入]]