--- title: 【记录】使用acme.sh签发泛域名证书 urlname: use-acme.sh-to-issue-certificates index_img: https://api.limour.top/randomImg?d=2024-06-28 17:03:35 date: 2024-06-29 01:03:35 tags: acme --- `.top` 域名的 `KSK` 密钥轮替,不知道为什么把 `Let's Encrypt` 的 `DNSSEC` 验证流量阻断了,导致 `Nginx Proxy Manager` 现在无法续签证书,因此用 `acme.sh` 来申请其他家的证书暂时替代一下了。([DNSSEC: DNSKEY Missing](https://community.letsencrypt.org/t/dns-problem-looking-up-a-for-xxx-domain-top-dnssec-dnskey-missing-no-valid-aaaa-records-found-for-xxx-domain-top/220650)) ## 准备工作 1. 安装 acme.sh:`curl https://get.acme.sh | sh -s email=limour@limour.top` 2. 获取 CF_Token:我的个人资料 - API 令牌 - 创建令牌 - 编辑区域 DNS 模板 3. 获取 CF_Zone_ID: 域名页 - 概览 - 右侧下滑 - API - 区域 ID ## 申请证书 ```bash export CF_Token="Y_jpG9AnfQmuX5Ss9M_qaNab6SQwme3HWXNDzRWs" export CF_Zone_ID="763eac4f1bcebd8b5c95e9fc50d010b4" ~/.acme.sh/acme.sh --issue --dns dns_cf -d *.limour.top -d limour.top -k ec-256 ``` + 不能只写 `-d *.limour.top`, 需要再加一个 `-d limour.top` + 记录下 `.key` 的路径和 `fullchain.cer` 的路径 ## 传递证书 ### SSH免密 ```bash ssh-keygen -t rsa ssh-copy-id root@xxx.limour.top ``` ### 传递脚本 ```bash nano scp_cert.sh && chmod +x scp_cert.sh ``` ```bash #!/bin/bash scp /root/.acme.sh/*.limour.top_ecc/*.limour.top.key root@xxx.limour.top:/root/app/quic/my.key scp /root/.acme.sh/*.limour.top_ecc/fullchain.cer root@xxx.limour.top:/root/app/quic/my.cert ``` ### 计划任务 ```bash crontab -e 50 22 1 * * /root/scp_cert.sh ```