居然还在使用付费的https证书?
网站的https证书过期了一直使用阿里云的免费ssl证书但是现在阿里云调整了策略[1]证书有效期从1年缩短到3个月了所以我决定放弃阿里云转而使用 Let’s Encrypt[2] 申请免费证书。简介Let’s Encrypt 是一家免费、开放、自动化的公益性证书颁发机构CA 由互联网安全研究组[3]ISRG运作详细介绍可以看这里[4]。申请证书按照官方文档[5]对于没有命令行访问权限的网站比如wordpress、cPanel等可以通过控制台设置或者申请后手动上传证书而我的网站服务器托管在阿里云拥有命令行访问权限所以直接使用官方推荐的 Certbot[6] ACME 客户端来管理证书这里详细记录下步骤。CertBot[7] 文档有详细的安装步骤我的 ubuntu14 上的步骤如下安装 snapdsnap[8] 是linux的应用程序包可以从其自身的snap store中安装、管理软件有点类似包管理器如 apt、yum但是不依赖linux发行版安全、跨平台且无依赖而 snapd 则是一个自动管理和维护 snap 的后台服务它们之间的区别请参阅官方文档[9]。Ubuntu 16.04LTS版及之上的版本已经集成了snapd无需再安装了而我的是 14所以需要手动安装。sudo apt update sudo apt install snapd测试是否安装成功可以安装官方的 hello-world 程序:$ snap install hello-world 2024-06-09T16:15:3908:00 INFO Waiting for automatic snapd restart... hello-world 6.4 from Canonical✓ installed执行并成功输出信息表示安装成功:$ hello-world Hello World!删除 certbot-auto 和任何 Certbot OS 软件包如果您使用操作系统包管理器如apt、dnf或yum安装了任何 Certbot 包则应在安装 Certbot snap 之前删除它们以确保运行命令certbot时将使用 snap而不是从操作系统包管理器进行安装。执行此操作的确切命令取决于您的操作系统但常见的示例是sudo apt-get remove certbot、sudo dnf remove certbot或sudo yum remove certbot。Ubuntu 14上并没有安装certbot-auto:$ apt-get remove certbot Reading package lists... Done Building dependency tree Reading state information... Done Package certbot is not installed, so not removed …… 0 upgraded, 0 newly installed, 0 to remove and 260 not upgraded.安装 Certbotok现在可以使用 snap 安装 Certbot 了:$ snap install --classic certbot certbot 2.11.0 from Certbot Project (certbot-eff✓) installed然后做一个软件链接方便执行:sudo ln -s /snap/bin/certbot /usr/bin/certbot获取并安装证书这是最简单的方式直接执行 certbot 申请证书并自动安装到 nginx:$ certbot --nginx Saving debug log to /var/log/letsencrypt/letsencrypt.log Enter email address (used for urgent renewal and security notices) ……这期间会询问多次主要是输入邮箱地址、同意协议、根据nginx已经配置的域名来选择需要启用https证书的域名等最后安装成功会输入如下信息:Congratulations! You have successfully enabled HTTPS on https://hankmo.com, https://bitcoinbook.hankmo.com, https://jason.hankmo.com, and https://jimmy.hankmo.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - If you like Certbot, please consider supporting our work by: * Donating to ISRG / Lets Encrypt: https://letsencrypt.org/donate * Donating to EFF: https://eff.org/donate-le - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -如果nginx没有准备好仍然可以手动获取证书后续再手动配置:sudo certbot certonly --nginx测试自动续订您系统上的 Certbot 软件包附带一个 cron 作业或 systemd 计时器可在证书过期之前自动更新您的证书。您不需要再次运行 Certbot除非您更改配置。您可以通过运行以下命令来测试证书的自动续订sudo certbot renew --dry-run续订 certbot 的命令安装在以下位置之一/etc/crontab//etc/cron.*/*systemctl list-timers比如我的机器上timer如下$ systemctl list-timers NEXT LEFT LAST PASSED UNIT ACTIVATES Mon 2024-06-10 05:28:00 CST 12h left Sun 2024-06-09 16:31:32 CST 46min ago snap.certbot.renew.timer snap.certbot.renew.service检查证书是否已经生效现在访问网站可以看到证书已经生效说明证书安装成功。总结Lets Encryot 是一个免费颁发https证书的组织它提供了 Certbot 工具方便地为我们申请、安装证书不过它需要使用 snap 来安装整个过程其实比较简单完成后您的网站就可以通过 https 访问了。参考:Lets Encrypt 官方文档: https://letsencrypt.org/zh-cn/getting-started/[10]Certbot 官方文档: https://certbot.eff.org/instructions?wsnginxosubuntuxenial[11]snap 官方安装文档: https://snapcraft.io/docs/installing-snapd[12]引用链接[1] 调整了策略: https://help.aliyun.com/zh/ssl-certificate/product-overview/notice-on-adjustment-of-service-policies-for-free-certificates?spm0.2020520163.help.dexternal.62d23711Eoxaa5[2] Let’s Encrypt: https://letsencrypt.org/[3] 互联网安全研究组: https://www.abetterinternet.org/[4] 这里: https://letsencrypt.org/zh-cn/about/[5] 官方文档: https://letsencrypt.org/zh-cn/getting-started/[6] Certbot: https://certbot.eff.org/[7] CertBot: https://certbot.eff.org/instructions?wsnginxosubuntuxenial[8] snap: https://snapcraft.io/docs[9] 官方文档: https://snapcraft.io/about[10] https://letsencrypt.org/zh-cn/getting-started/: https://letsencrypt.org/zh-cn/getting-started/[11] https://certbot.eff.org/instructions?wsnginxosubuntuxenial: https://certbot.eff.org/instructions?wsnginxosubuntuxenial[12] https://snapcraft.io/docs/installing-snapd: https://snapcraft.io/docs/installing-snapd
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2429433.html
如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!