首页 > 解决方案 > 修复,让 Let's Encrypt 与 www 一起使用

问题描述

Firefox 不信任此站点,因为它使用的证书对www.example.com无效。证书仅对 example.com 有效。

错误代码:SSL_ERROR_BAD_CERT_DOMAIN

我在 Ubuntu 16、Apache httpd 上使用 Let's Encrypt。

如何添加它也适用于www?我猜是Apache中的一些conf?

找不到任何关于它的东西。

标签: apacheubuntulets-encrypt

解决方案


假设您已安装certbot适用于您的 Ubuntu 和 Apache 版本的文档),您应该使用-d命令行开关列出您希望证书适用的域。 从文档

 -d DOMAIN, --domains DOMAIN, --domain DOMAIN
                   Domain names to apply. For multiple domains you can
                   use multiple -d flags or enter a comma separated list
                   of domains as a parameter. The first domain provided
                   will be the subject CN of the certificate, and all
                   domains will be Subject Alternative Names on the
                   certificate. The first domain will also be used in
                   ...

如果您想进行试运行以进行测试,请使用certonlyand --dry-run(您必须使用 asroot或 with运行sudo):

certbot certonly --dry-run -d www.example.com -d example.com

如果看起来一切正常,实际生成、安装和激活证书(注意这将重新启动 Apache):

certbot --apache -d www.example.com -d example.com

certbot将为您对 Apache 配置进行必要的编辑。

如果您希望手动进行编辑,请使用该webroot选项。 该选项的文档包括对多个域执行此操作的示例,包括 example.com 和www.example.com。从该示例中删除其他域以简化这种情况:

certbot certonly --webroot -w /var/www/example -d www.example.com -d example.com

使用此选项时,您需要自己重新启动 Apache 才能使用新证书。


推荐阅读