惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

阮一峰的网络日志
阮一峰的网络日志
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Blog — PlanetScale
Blog — PlanetScale
Jina AI
Jina AI
MyScale Blog
MyScale Blog
N
Netflix TechBlog - Medium
月光博客
月光博客
云风的 BLOG
云风的 BLOG
T
The Blog of Author Tim Ferriss
博客园_首页
GbyAI
GbyAI
The Cloudflare Blog
博客园 - 叶小钗
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
MongoDB | Blog
MongoDB | Blog
Y
Y Combinator Blog
博客园 - 三生石上(FineUI控件)
量子位
博客园 - Franky
WordPress大学
WordPress大学
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
人人都是产品经理
人人都是产品经理
F
Fortinet All Blogs
Martin Fowler
Martin Fowler
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
M
MIT News - Artificial intelligence
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
I
InfoQ
Google DeepMind News
Google DeepMind News
S
SegmentFault 最新的问题
大猫的无限游戏
大猫的无限游戏
Apple Machine Learning Research
Apple Machine Learning Research
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Stack Overflow Blog
Stack Overflow Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Last Week in AI
Last Week in AI
J
Java Code Geeks
腾讯CDC
aimingoo的专栏
aimingoo的专栏
C
Check Point Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
V
Vulnerabilities – Threatpost
S
Schneier on Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
L
Lohrmann on Cybersecurity
S
Securelist
F
Full Disclosure
Cisco Talos Blog
Cisco Talos Blog
小众软件
小众软件
The GitHub Blog
The GitHub Blog

Allen Hua 的网络博客

由于 Linux 桌面没有一个好用的天气程序就写了一个跨平台的CheckitoutWeather 给 caesium-image-compressor 图片压缩程序构建了 Linux AppImage v2.8.5 最新版 debian13(debian trixie)安装了nvidia闭源驱动后从x11切换到wayland的方法 山间摩旅追风,偶遇一场绚烂晚霞 最近使用debian系统的一些心得 机械革命无界14Pro笔记本debian forky成功驱动内置扬声器和麦克风 记录 typecho 1.2.0 升级到 1.3.0 过程 开发了一款openwrt插件:文本剪贴板 解决机械革命笔记本内屏高刷240Hz闪屏问题 使用 Java 写了一个局域网端口扫描器 - Allen Hua 的网络博客 openwrt使用外置根extroot机制扩展根分区大小 - Allen Hua 的网络博客 将机场ss节点批量转换成ss字符串链接批量添加到passwall - Allen Hua 的网络博客 给机械革命钛钽plus换屏:NY2换成NZ2 - Allen Hua 的网络博客 记录一次pve宿主机和上面的debian虚机无故down机事件 - Allen Hua 的网络博客 给图床部署cdn腾讯云的edgeone并排查Cache-Control max-age 3600的问题 - Allen Hua 的网络博客 从高山草甸到徽派古村:武功山反穿与皖浙赣自驾行记 - Allen Hua 的网络博客 增程器就是充电宝?别被忽悠了 - Allen Hua 的网络博客 浦口龙虎巷扫街,记录人间真实 博客图片压缩方案更新|AVIF|WebP|MozJPEG|标准JPEG Windows 电脑使用 Obs Studio 录制各个网站视频/桌面画面教程 为typecho博客添加latex支持 新能源汽车之纯电车使用交流慢充和直流快充的充电损耗对比 2025年3月更新全国5A景区名录 2025最新查看小米/红米手机电池健康度和循环次数方法 完美解决 seafile FILE_SERVER_ROOT 配置导致的内网外网不能同时访问和上传下载的问题 纯css实现typecho博客文章文字spoiler剧透效果 我对Typecho Facile主题的一些修改,图片懒加载优化,样式定制 2024年8月我的宜昌 - 重庆 - 川西小环线自驾旅行分享 2022年打卡南京市区人防工程纳凉点 2024年带着A7C2+腾龙28-200 再次来到红山森林动物园 入手a7c2第一个变焦镜头腾龙28-200体验分享 使用 exiftool 方便快捷写入图片的 exif metadata 使用JavaScript抓取易车销量排行榜数据到一个页面上展示 使用JavaScript脚本快速获取B站观看历史记录页面的视频标题和URL 入门三脚架推荐|云腾VCT-668配合索尼A7C2+FE 35mm F1.8 第一次夜景出片 Windows 11 Docker Desktop 更换默认C盘存储路径,释放C盘空间 雨游钟山——雨天带着索尼A7C2去钟山拍照 带上A7C2第一次扫街,分享今天拍的一些片子 再次为尼,买了人生第二台相机——索尼A7C2和FE 35mm F1.8 定焦镜头 更新 link-cleaner v1.1.0 适配linux桌面环境 使用自定义JavaScript脚本功能禁止memos最新版默认打开的链接预览功能 debian 11升级 docker ce 版本和 docker-compose 版本 机械革命无界14 Pro 安装 debian testing/trixie/sid 驱动扬声器,外部耳机,外接显示器过程分享 不借助 mirror 仓库,为docker engine daemon添加 proxy 访问 docker hub,解决国内公开的docker mirror 仓库不再可用了的问题 徒步江苏镇江句容九连尖 macOS 安装 proxychains-ng 并借助局域网 socks5 代理使用 Google Earth Pro 修复一块 18 年 12 月买的二手 4TB 机械硬盘 iCloud 在 Windows 下很流氓,用 taskkill 干掉它 2023 年 12 月 Spotify 彻底被墙,我在比亚迪车机上安装 surfboard 挂代理听歌 利用 proxychains 让 Windows10/11 上的 Google Earth Pro 通过代理正常访问 湖州安吉天荒坪盘山公路和杭州临安浙西天路之旅 Redmi K70 首发开箱和拍照体验 Review Android 13+ 通过 Shizuku + Language Selector 给特定应用设置独立语言 我的 2023 Spotify Wrapped 听歌总结 压缩剪贴板内图片并立即写入剪贴板,减轻服务器存储压力 【Allen Hua 翻唱】山阴路的夏天和一个人的北京 初涉录音设备,记录我购买声卡和麦克风的曲折经历以及第一首翻唱陶喆——流沙 soul power 版本(low quality) 特种兵旅行之马鞍山一日游 给我的 .com 域名续期以及转移域名(GoDaddy 到 Cloudflare) 看《下辈子我再好好过》第三季 使用油猴脚本干掉B站web首页的浏览器插件警告信息 闯进我平静生活的三只猫 在远离中短视频几天之后 [可能是]最好的压缩图片程序,使用 squoosh-cli 批量压缩图片 再次出发,自驾徽州天路和黄山之行 nginx设置referer配置个人图床的防盗链功能 微博注销记 第一次4+2旅行,骑行皖南川藏线 让 rime 输入法用上颜文字 使用 nginx 获取自己的公网 IP 地址 2023 年 618 买了一台机械革命笔记本,但很不愉快 聊聊我晚睡的习惯和早点洗澡悟出来的原因 配置 ShadowsocksR Plus+ 的服务端,在外访问家中服务 部署一个 memos 作为个人微博站点和备忘录 我的听歌软件 Spotify 和网易云的故事 | 导出网易云的歌单再导入到 Spotify 我问 ChatGPT 为何印度人痔疮发病率低 使用 immich 来管理家庭照片 | 升级 immich 1.52.0 添加 typesense 容器 在 OpenWrt 上搭建 nfs server 利用 cron 和 curl 自动模拟登录馒头,防止账号被 ban 更新 Mattermost 服务端版本,由 7.4.0 更新到 7.8.0 获取 Seafile 分享的文件直链 你是科技产品偏执狂吗?一张不同种类互联网用户日常使用产品的分级图片 记录我的 V2EX 账号被封 不通过插件给 Typecho 博客添加图片灯箱功能(fancybox js 实现) 为 Typecho 博客添加 favicon.ico(网页标签小图标) OpenWrt 修改登录页面默认展示的 root 用户名信息,保护隐私 米家智能插座 3 上手初体验 互联网上为了保护隐私我们能做些什么?分享我的想法和我写的 link-cleaner tplink 10280, wan 无法访问 lan 下的 dhcp 主机,换上 padavan 解决两台路由器 lan-wan 级联,两台路由器下面的电脑互访 机械革命自带键盘总是自动乱按,拆机拔掉排线,完美解决烦恼 做了一个 squoosh docker 镜像,写博客贴图直接在本地压缩文件,安全且高效 nginx 常规端口和非常规端口的 http redirect to https 记一次 OpenWrt luci 显示正在“收集数据”,使用公网 IP nginx 反向代理遇到的 Uncaught TypeError: Cannot read properties of null (reading 'wan') 问题 OpenWrt 安装并配置腾讯云动态 dns dnspod tencent ddns 浅谈文件传输/共享协议|内网共享文件协议选择|自建公网文件管理同步和共享方案推荐 解决 webdav 连接 seafile 无法重命名文件等操作造成的 SeafDAV: MOVE returns 502 Bad Gateway 错误 Linux 删除当前目录下的隐藏文件 OpenWrt 安装 4.4.2 版本的 qbittorrent-nox Docker 构建多架构镜像实战 构建 amd64 和 arm64 架构的兰空图床镜像 构建 arm64 架构和 amd64 架构的兰空图床 docker 镜像
使用certbot自动给通配符证书续期
Allen Hua · 2021-04-09 · via Allen Hua 的网络博客
阅读量:3353

warning: 这篇文章距离上次修改已过1868天,其中的内容可能已经有所变动。

今晚发现 hellodk.com 的几个网站的证书过期(比如 https://router.hellodk.com )无法访问,然后续期证书遇到问题,本文记录解决过程。

由于之前是配置了 crontab 脚本定期续期证书的,没有成功续上那就肯定是程序执行出错了。检查 cron 日志发现下面这个报错

PluginError('An authentication script must be provided with
--manual-auth-hook when using the manual plugin non-interactively godaddy

出现这个错误的原因是 certbot 无法直接更新你的域名的DNS记录中的 TXT 记录值导致更新失败

因为推荐的申请泛域名证书/通配符证书的方式是--preferred-challenges dns dns challenge 模式。这是使用 DNS 方式校验域名所有权,域名验证 dns 解析需要增加 TXT 类型的解析配置,子域名为_acme-challenge 默认情况下需要你自己去域名服务商(比如 阿里云 腾讯云 华为云 godaddy等) dns 解析那里去配置。如果想要通过命令行直接更新 txt 值就要利用 certbot 提供的 hook 函数,我们在shell 中调用DNS服务商的相关API接口就可以动态的更新TXT记录了

就是这样一个原理。好在已经有大神写出来了相关的项目了。因为我的域名服务商使用的是 godaddy 所以找了一个支持 godaddy的github项目: https://github.com/ywdblog/certbot-letencrypt-wildcardcertificates-alydns-au

仔细阅读大神项目的 readme 文档


重要的几个点

  1. 确定你的 au.sh 文件有执行权限
  2. 确定你域名的根域名在 domain.ini 文件中存在,如果不存在就自行添加一行
  3. 获取 DNS API 密钥,这个 API 密钥是用来认证你的用户身份以及授权http请求(因为你要通过调用服务商的 api 来更新 TXT 记录的值)
  4. 将获取的或者是新建的 api key 和 secret 填在 au.sh 文件中
  5. 先利用 certbot 的--dry-run 选项进行一次证书申请的测试
  6. 测试成功后再进行证书申请(或者是续期)
  7. 确定调用dns服务商的hook 是用的 python 还是 php,这个项目中腾讯云、阿里云、华为云都是用的python,而godaddy是php。要确保你的机器安装了python或php,否则肯定会报 command not found 之类的错误
  8. 这个项目中,aly 是阿里云;txy 是腾讯云;hwy 是华为云;godaddy 是 godaddy

附上一个小插曲,centOS7 安装 php7 的教程: https://linuxize.com/post/install-php-7-on-centos-7/

简而言之就是下面几条命令

  1. yum install epel-release yum-utils
  2. yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
  3. yum-config-manager --enable remi-php73
  4. yum install php php-common php-opcache php-mcrypt php-cli php-gd php-curl php-mysqlnd

执行 php -v 有版本输出代表本机的php7成功安装

$ php -v
PHP 7.3.27 (cli) (built: Feb  2 2021 10:32:50) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.27, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.27, Copyright (c) 1999-2018, by Zend Technologies

在开始之前,建议执行 certbot certificates 查看本机安装的证书,使用certbot delete 删除不需要的证书再开始(删除的时候是交互式的,放心大胆的执行 certbot delete 没事,会让你选择数字然后yes确认,或者直接按c取消操作)

测试申请通配符证书

带上 --dry-run 选项

certbot certonly -d "*.hellodk.com" -d hellodk.com \
--manual --preferred-challenges dns --dry-run \
--manual-auth-hook "/root/temp/certbot-letencrypt-wildcardcertificates-alydns-au/au.sh php godaddy add" \
--manual-cleanup-hook "/root/temp/certbot-letencrypt-wildcardcertificates-alydns-au/au.sh php godaddy clean"

下面这是测试时候的日志

[root@justhostRU /]# certbot certonly -d "*.hellodk.com" -d hellodk.com --manual --preferred-challenges dns --dry-run --manual-auth-hook "/root/temp/certbot-letencrypt-wildcardcertificates-alydns-au/au.sh php godaddy add" --manual-cleanup-hook "/root/temp/certbot-letencrypt-wildcardcertificates-alydns-au/au.sh php godaddy clean"
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator manual, Installer None
Cert is due for renewal, auto-renewing...
Simulating renewal of an existing certificate for *.hellodk.com and hellodk.com
Performing the following challenges:
dns-01 challenge for hellodk.com
dns-01 challenge for hellodk.com
Running manual-auth-hook command: /root/temp/certbot-letencrypt-wildcardcertificates-alydns-au/au.sh php godaddy add
Running manual-auth-hook command: /root/temp/certbot-letencrypt-wildcardcertificates-alydns-au/au.sh php godaddy add
Waiting for verification...
Cleaning up challenges
Running manual-cleanup-hook command: /root/temp/certbot-letencrypt-wildcardcertificates-alydns-au/au.sh php godaddy clean
Running manual-cleanup-hook command: /root/temp/certbot-letencrypt-wildcardcertificates-alydns-au/au.sh php godaddy clean

IMPORTANT NOTES:
 - The dry run was successful.

如果有 IMPORTANT NOTES: - The dry run was successful. 的日志输出,那么说明 api key 和 secret 配置的肯定是正确的,说明成功请求到 dns 服务商的 api,然后就可以进行接下来的续期操作了

接着是实际上的续期证书

命令

certbot renew --manual --preferred-challenges dns \
--manual-auth-hook "/root/temp/certbot-letencrypt-wildcardcertificates-alydns-au/au.sh php godaddy add" \
--manual-cleanup-hook "/root/temp/certbot-letencrypt-wildcardcertificates-alydns-au/au.sh php godaddy clean"

下面这是实际续期时候的日志

[root@justhostRU /]# certbot renew --manual --preferred-challenges dns --manual-auth-hook "/root/temp/certbot-letencrypt-wildcardcertificates-alydns-au/au.sh php godaddy add" --manual-cleanup-hook "/root/temp/certbot-letencrypt-wildcardcertificates-alydns-au/au.sh php godaddy clean"
Saving debug log to /var/log/letsencrypt/letsencrypt.log

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing /etc/letsencrypt/renewal/hellodk.com.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cert is due for renewal, auto-renewing...
Plugins selected: Authenticator manual, Installer None
Renewing an existing certificate for *.hellodk.com and hellodk.com
Performing the following challenges:
dns-01 challenge for hellodk.com
dns-01 challenge for hellodk.com
Running manual-auth-hook command: /root/temp/certbot-letencrypt-wildcardcertificates-alydns-au/au.sh php godaddy add
Running manual-auth-hook command: /root/temp/certbot-letencrypt-wildcardcertificates-alydns-au/au.sh php godaddy add
Waiting for verification...
Cleaning up challenges
Running manual-cleanup-hook command: /root/temp/certbot-letencrypt-wildcardcertificates-alydns-au/au.sh php godaddy clean
Running manual-cleanup-hook command: /root/temp/certbot-letencrypt-wildcardcertificates-alydns-au/au.sh php godaddy clean

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
new certificate deployed without reload, fullchain is
/etc/letsencrypt/live/hellodk.com/fullchain.pem
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations, all renewals succeeded:
  /etc/letsencrypt/live/hellodk.com/fullchain.pem (success)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

成功续期

执行一下 nginx -s reload

网页访问 https://router.hellodk.com

20210409231517.png

成功续期

修改/添加 crontab 脚本

# 每当 7月 10月 1月 4月 的 7号 上午9点 执行命令,续期通配符证书
0 9 7 7,10,1,4 * /usr/bin/certbot renew --manual --preferred-challenges dns --manual-auth-hook "/root/temp/certbot-letencrypt-wildcardcertificates-alydns-au/au.sh php godaddy add" --manual-cleanup-hook "/root/temp/certbot-letencrypt-wildcardcertificates-alydns-au/au.sh php godaddy clean" --renew-hook "/usr/sbin/nginx -s reload"

crontab -e 将上面的命令追加到末尾

# 重载 crond 服务
systemctl reload crond.service

# 重启 crond 服务
systemctl restart crond.service

这样一来,7月、10月、2022年1月、2022年4月(后面不断推进时间……)的7号上午的9点都会自动的续期通配符证书,https服务可以不间断的运行了。本文的分享结束

end.