安装 Let’s Encrypt 证书

June 29, 2023

Let’s Encrypt 安装证书的方法, ChatGPT 提供

Let’s Encrypt 提供了一个免费、自动化、开放的证书颁发平台,让您可以获得和安装 SSL/TLS 证书,从而使你的网站能够通过 HTTPS 提供服务。下面是一个基本的使用 certbot 自动化安装 Let’s Encrypt 证书的步骤,以 Debian/Ubuntu 为例:

  1. 安装 Certbot 客户端:
  1. 配置 Apache 来使用 SSL:

$sudo certbot --apache -d your-domain.com -d www.your-domain.com

在这里,你需要将 your-domain.comwww.your-domain.com 替换成你的实际域名。

  1. 检查自动更新设置:

Let’s Encrypt 的证书每 90 天需要更新一次,Certbot 会自动为你做这个工作。你可以通过运行以下命令来检查它是否正常工作:

这将模拟证书续订过程,以便您可以确认其自动更新正常。

以上就是通过 Certbot 在 Ubuntu/Debian 上自动化安装 Let’s Encrypt 证书的基本步骤。如果你使用的是其它的系统或者 web server,比如 CentOS 或者 Nginx,步骤可能会有所不同,你可以参考 Certbot 的官方文档进行操作。

root@mail:/home/ubuntu# add-apt-repository ppa:certbot/certbot PPA publishes dbgsym, you may need to include ‘main/debug’ component Repository: ‘deb https://ppa.launchpadcontent.net/certbot/certbot/ubuntu/ jammy main’ Description: The PPA has been DEPRECATED. To get up to date instructions on how to get certbot for your systems, please see https://certbot.eff.org/docs/install.html. More info: https://launchpad.net/~certbot/+archive/ubuntu/certbot Adding repository. Press [ENTER] to continue or Ctrl-c to cancel. Adding deb entry to /etc/apt/sources.list.d/certbot-ubuntu-certbot-jammy.list Adding disabled deb-src entry to /etc/apt/sources.list.d/certbot-ubuntu-certbot-jammy.list Adding key to /etc/apt/trusted.gpg.d/certbot-ubuntu-certbot.gpg with fingerprint 7BF576066ADA65728FC7E70A8C47BE8E75BCA694 Failed to start apt-news.service: Unit apt-news.service not found. Failed to start esm-cache.service: Unit esm-cache.service not found. Hit:1 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu jammy InRelease Hit:2 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu jammy-updates InRelease Hit:3 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu jammy-backports InRelease Hit:4 http://security.ubuntu.com/ubuntu jammy-security InRelease Ign:5 https://ppa.launchpadcontent.net/certbot/certbot/ubuntu jammy InRelease Hit:6 https://ppa.launchpadcontent.net/groonga/ppa/ubuntu jammy InRelease Err:7 https://ppa.launchpadcontent.net/certbot/certbot/ubuntu jammy Release 404 Not Found [IP: 185.125.190.52 443] Reading package lists… Done E: The repository ‘https://ppa.launchpadcontent.net/certbot/certbot/ubuntu jammy Release’ does not have a Release file. N: Updating from such a repository can’t be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details. root@mail:/home/ubuntu#ChatGPT

从你的命令输出看,certbot/certbot 这个 PPA 已经被弃用了。你应该遵循 Certbot 的新的安装指南。你的 Ubuntu 版本可能比我之前的建议更加新,因此,你应该使用 snapd 来安装 certbot。以下是通过 snap 安装 Certbot 的步骤:

  1. 如果你的系统上还没有安装 snapd,你需要首先安装它:
  1. 使用 snap 安装 Certbot:
  1. 确保 Certbot 命令可在路径中找到:
  1. 运行 Certbot 来配置你的 SSL:

这个命令将会自动获取和配置 SSL 证书。根据提示操作,你可能需要提供你的邮箱地址和同意服务条款。在询问是否设置 HTTPS 重定向时,选择 “Secure”。

  1. 检查自动更新设置:

这将模拟证书续订过程,以便您可以确认其自动更新正常。

以上就是通过 snap 在 Ubuntu 上安装 Certbot 的步骤。这些步骤应该适用于 Ubuntu 20.04 和更高版本。如果你遇到任何问题,可以参考 Certbot 的官方文档

hich names would you like to activate HTTPS for? We recommend selecting either all domains, or all domains in a VirtualHost/server block. – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – 1: huihui.ai – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – Select the appropriate numbers separated by commas and/or spaces, or leave input blank to select all options shown (Enter ‘c’ to cancel): 1 Requesting a certificate for huihui.ai live directory exists for huihui.ai Ask for help or search for solutions at https://community.letsencrypt.org. See the logfile /var/log/letsencrypt/letsencrypt.log or re-run Certbot with -v for more details.ChatGPT

你遇到的问题可能是由于尝试为已经存在的证书请求新的证书。live directory exists for huihui.ai 这个信息意味着已经有一个针对 huihui.ai 的证书存在。

如果你只是想更新现有的证书,你可以直接运行:

如果你想要为 huihui.ai 请求新的证书并覆盖现有的证书,你可以使用 --cert-name 参数:

这将会更新指定名称的证书而不是创建新的证书。或者,如果你想要强制创建一个新的证书并覆盖已经存在的证书,你可以使用 --duplicate 参数:

但是要注意,重复的证书请求可能会触发 Let’s Encrypt 的频率限制,所以只有在必要的时候才使用这个选项。

这些操作都需要根据 Certbot 的提示完成步骤,可能包括提供邮箱地址、同意服务条款、以及设置 HTTPS 重定向等等。如果遇到问题,你可以查看 /var/log/letsencrypt/letsencrypt.log 日志文件获取更多信息,或者在 Let’s Encrypt 社区寻求帮助。

发表评论

您的电子邮箱地址不会被公开。 必填项已用 * 标注

滚动至顶部