LMLPHP后院

acme letsencrypt 折腾记技术

maybe yes 发表于 2022-09-30 18:01

acme 折腾记,更便捷的申请证书,可是咱们毕竟不是域名服务商,难以做到像 CF 那样牛逼。

我不喜欢这个脚本,强制安装,安装只是复制文件,添加链接,自动任务。并且还一定要注册,越来越难用了。

以下是折腾记录

pi@raspberrypi:~/work/acme $ acme.sh  --issue  --dns  -d godruoyi.com -d *.godruoyi.com
-bash: acme.sh:未找到命令
pi@raspberrypi:~/work/acme $ bash acme.sh --issue --dns -d x.com -d *.x.com
[2022年 09月 30日 星期五 16:29:12 CST] It seems that you are using dns manual mode. Read this link first: https://github.com/acmesh-official/acme.sh/wiki/dns-manual-mode
pi@raspberrypi:~/work/acme $ bash acme.sh --issue --dns -d x.com -d *.x.com --yes-I-know-dns-manual-mode-enough-go-ahead-please
[2022年 09月 30日 星期五 16:30:47 CST] Using CA: https://acme.zerossl.com/v2/DV90
[2022年 09月 30日 星期五 16:30:47 CST] Create account key ok.
[2022年 09月 30日 星期五 16:30:47 CST] No EAB credentials found for ZeroSSL, let's get one
[2022年 09月 30日 星期五 16:30:47 CST] acme.sh is using ZeroSSL as default CA now.
[2022年 09月 30日 星期五 16:30:47 CST] Please update your account with an email address first.
[2022年 09月 30日 星期五 16:30:47 CST] acme.sh --register-account -m my@example.com
[2022年 09月 30日 星期五 16:30:47 CST] See: https://github.com/acmesh-official/acme.sh/wiki/ZeroSSL.com-CA
[2022年 09月 30日 星期五 16:30:47 CST] Please add '--debug' or '--log' to check more details.
[2022年 09月 30日 星期五 16:30:47 CST] See: https://github.com/acmesh-official/acme.sh/wiki/How-to-debug-acme.sh
pi@raspberrypi:~/work/acme $ vim acme.sh 
pi@raspberrypi:~/work/acme $ acme.sh --register-account -m x@gmail.com
-bash: acme.sh:未找到命令
pi@raspberrypi:~/work/acme $ bash acme.sh --register-account -m x@gmail.com
[2022年 09月 30日 星期五 16:33:07 CST] No EAB credentials found for ZeroSSL, let's get one
[2022年 09月 30日 星期五 16:33:09 CST] Registering account: https://acme.zerossl.com/v2/DV90
[2022年 09月 30日 星期五 16:33:27 CST] Registered
[2022年 09月 30日 星期五 16:33:27 CST] ACCOUNT_THUMBPRINT='WHQQJ-H2154vB4Yo7J_YU-7gmht5PgF03Z-8vd5qU_0'
pi@raspberrypi:~/work/acme $ bash acme.sh --issue --dns -d x.com -d *.x.com --yes-I-know-dns-manual-mode-enough-go-ahead-please
[2022年 09月 30日 星期五 16:33:54 CST] Using CA: https://acme.zerossl.com/v2/DV90
[2022年 09月 30日 星期五 16:33:54 CST] Creating domain key
[2022年 09月 30日 星期五 16:33:54 CST] The domain key is here: /home/pi/.acme.sh/x.com/x.com.key
[2022年 09月 30日 星期五 16:33:55 CST] Multi domain='DNS:x.com,DNS:*.x.com'
[2022年 09月 30日 星期五 16:33:55 CST] Getting domain auth token for each domain
[2022年 09月 30日 星期五 16:34:35 CST] Getting webroot for domain='x.com'
[2022年 09月 30日 星期五 16:34:35 CST] Getting webroot for domain='*.x.com'
[2022年 09月 30日 星期五 16:34:35 CST] Add the following TXT record:
[2022年 09月 30日 星期五 16:34:35 CST] Domain: '_acme-challenge.x.com'
[2022年 09月 30日 星期五 16:34:35 CST] TXT value: '1QmQCMSLPlPPTnZJcTcNRuobYUFvPwpKJTedxe8DCfE'
[2022年 09月 30日 星期五 16:34:35 CST] Please be aware that you prepend _acme-challenge. before your domain
[2022年 09月 30日 星期五 16:34:35 CST] so the resulting subdomain will be: _acme-challenge.x.com
[2022年 09月 30日 星期五 16:34:35 CST] Add the following TXT record:
[2022年 09月 30日 星期五 16:34:35 CST] Domain: '_acme-challenge.x.com'
[2022年 09月 30日 星期五 16:34:35 CST] TXT value: 'KUziMmpJzuPkEZOHKzmrcL8B9Q5pTnTYUx4lDjBr_S4'
[2022年 09月 30日 星期五 16:34:35 CST] Please be aware that you prepend _acme-challenge. before your domain
[2022年 09月 30日 星期五 16:34:35 CST] so the resulting subdomain will be: _acme-challenge.x.com
[2022年 09月 30日 星期五 16:34:35 CST] Please add the TXT records to the domains, and re-run with --renew.
[2022年 09月 30日 星期五 16:34:35 CST] Please add '--debug' or '--log' to check more details.
[2022年 09月 30日 星期五 16:34:35 CST] See: https://github.com/acmesh-official/acme.sh/wiki/How-to-debug-acme.sh

我选择 DNS 方式,只是为了泛解析,并且看网上的文档,泛解析需要指定域名和 *.yuming,我觉得好奇葩,并且你看看它的输出:

[2022年 09月 30日 星期五 16:34:35 CST] Add the following TXT record:
[2022年 09月 30日 星期五 16:34:35 CST] Domain: '_acme-challenge.x.com'
[2022年 09月 30日 星期五 16:34:35 CST] TXT value: '1QmQCMSLPlPPTnZJcTcNRuobYUFvPwpKJTedxe8DCfE'
[2022年 09月 30日 星期五 16:34:35 CST] Please be aware that you prepend _acme-challenge. before your domain
[2022年 09月 30日 星期五 16:34:35 CST] so the resulting subdomain will be: _acme-challenge.x.com
[2022年 09月 30日 星期五 16:34:35 CST] Add the following TXT record:
[2022年 09月 30日 星期五 16:34:35 CST] Domain: '_acme-challenge.x.com'
[2022年 09月 30日 星期五 16:34:35 CST] TXT value: 'KUziMmpJzuPkEZOHKzmrcL8B9Q5pTnTYUx4lDjBr_S4'
[2022年 09月 30日 星期五 16:34:35 CST] Please be aware that you prepend _acme-challenge. before your domain

以上把我整糊涂了,为什么两个是一样的二级验证的同时,TXT 的值却不一样,加上慢的像蜗牛一样的 namesilo,有的折腾了,后面折腾了几个小时没搞定,因为你一 renew,它的 TXT 就会发生变化,我去。

我发现 TXT 解析的二级域名可以重复,但是 nslookup 却只能查看到一条,这一步却是把我搞糊涂了。。。你敢将域名 API 的 KEY 交给它吗?并且很多域名服务商的 KEY 选择并不能用,因为套用了 CF,比如 NameSilo。

nslookup -type=TXT _acme-challenge.x.com
Server:		192.168.31.1
Address:	192.168.31.1#53

Non-authoritative answer:
_acme-challenge.x.com	text = "_YLwDcfzQ1tvW2S7SpAWVW7DfrClEbf6FA1NquC5x10"
_acme-challenge.x.com	text = "AZjJ9vODR2Rim5E2TvaPZksu1kGlNNHWmMrFutUBAJc"

Authoritative answers can be found from:
pi@raspberrypi:~/.acme.sh $ ./acme.sh --renew -d x.com -d *.x.com --dns --yes-I-know-dns-manual-mode-enough-go-ahead-please
[2022年 09月 30日 星期五 18:43:56 CST] Renew: 'x.com'
[2022年 09月 30日 星期五 18:43:56 CST] Renew to Le_API=https://acme.zerossl.com/v2/DV90
[2022年 09月 30日 星期五 18:44:02 CST] Using CA: https://acme.zerossl.com/v2/DV90
[2022年 09月 30日 星期五 18:44:03 CST] Multi domain='DNS:x.com,DNS:*.x.com'
[2022年 09月 30日 星期五 18:44:03 CST] Getting domain auth token for each domain
[2022年 09月 30日 星期五 18:44:03 CST] Verifying: x.com
[2022年 09月 30日 星期五 18:44:17 CST] Processing, The CA is processing your order, please just wait. (1/30)
[2022年 09月 30日 星期五 18:44:27 CST] Success
[2022年 09月 30日 星期五 18:44:27 CST] Verifying: *.x.com
[2022年 09月 30日 星期五 18:44:47 CST] Processing, The CA is processing your order, please just wait. (1/30)
[2022年 09月 30日 星期五 18:45:10 CST] Success
[2022年 09月 30日 星期五 18:45:10 CST] Verify finished, start to sign.
[2022年 09月 30日 星期五 18:45:10 CST] Lets finalize the order.
[2022年 09月 30日 星期五 18:45:10 CST] Le_OrderFinalize='https://acme.zerossl.com/v2/DV90/order/dMGjmnmGoKYN6PJOLg3kwQ/finalize'
[2022年 09月 30日 星期五 18:45:17 CST] Order status is processing, lets sleep and retry.
[2022年 09月 30日 星期五 18:45:17 CST] Retry after: 15
[2022年 09月 30日 星期五 18:45:33 CST] Polling order status: https://acme.zerossl.com/v2/DV90/order/dMGjmnmGoKYN6PJOLg3kwQ
[2022年 09月 30日 星期五 18:45:39 CST] Downloading cert.
[2022年 09月 30日 星期五 18:45:39 CST] Le_LinkCert='https://acme.zerossl.com/v2/DV90/cert/ql4v2AYC2IsfzNf_3z4tfA'
[2022年 09月 30日 星期五 18:45:47 CST] Cert success.
-----BEGIN CERTIFICATE-----
MIIGbTCCBFWgAwIBAgIQZqhug1aZS1p9S+p09gZOjjANBgkqhkiG9w0BAQwFADBL
...
-----END CERTIFICATE-----
[2022年 09月 30日 星期五 18:45:47 CST] Your cert is in: /home/pi/.acme.sh/x.com/x.com.cer
[2022年 09月 30日 星期五 18:45:47 CST] Your cert key is in: /home/pi/.acme.sh/x.com/x.com.key
[2022年 09月 30日 星期五 18:45:47 CST] The intermediate CA cert is in: /home/pi/.acme.sh/x.com/ca.cer
[2022年 09月 30日 星期五 18:45:47 CST] And the full chain certs is there: /home/pi/.acme.sh/x.com/fullchain.cer
2024-03-29 05:03:02 1711659782 0.013051