Let’s Encrypt实践指北( 二 )


certbot-auto certonly-d *.your_domain.com --manual --preferred-challenges dns--server https://acme-v02.api.letsencrypt.org/directory这里几个参数着重说一下:

  • certonly: 表示使用certbot只用来申请获取证书,而不做安装操作 。
  • -d: 域名 。这里注意,通配符证书一定配置为 *.domain.com,而不是 domain.com 。
  • —manual: 手动模式,理论上也可以选择DNS plugins 。
  • —preferred-challenges: 虽然manual模式下是同时支持两种验证方式的,而通配符证书需要采用dns-01验证方式
  • —server: ACME v2 验证使用的具体地址
返回的命令行输出如下:
Saving debug log to /var/log/letsencrypt/letsencrypt.logPlugins selected: Authenticator manual, Installer NoneEnter email address (used for urgent renewal and security notices) (Enter 'c' tocancel): your_email@gmail.com-------------------------------------------------------------------------------Please read the Terms of Service athttps://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You mustagree in order to register with the ACME server athttps://acme-v02.api.letsencrypt.org/directory-------------------------------------------------------------------------------(A)gree/(C)ancel: APlugins selected: Authenticator manual, Installer NoneObtaining a new certificatePerforming the following challenges:dns-01 challenge for your_domain.com-------------------------------------------------------------------------------NOTE: The IP of this machine will be publicly logged as having requested thiscertificate. If you're running certbot in manual mode on a machine that is notyour server, please ensure you're okay with that.Are you OK with your IP being logged?-------------------------------------------------------------------------------(Y)es/(N)o: y从这里开始需要一些交互:
  • 第一个:输入联系人的email,方便以后接受更新证书提醒和安全提示的
  • 第二个:同意条款
  • 第三个:记录此IP为申请证书的机器
DNS配置上步之后,命令行输出如下:
-------------------------------------------------------------------------------Please deploy a DNS TXT record under the name_acme-challenge.your_domain.com with the following value:`一串base64编码`Before continuing, verify the record is deployed.-------------------------------------------------------------------------------Press Enter to Continue这时不要着急继续,按照上述提示,需要去你的DNS服务提供商那里手动配置一条记录,用于验证你对此域名的所有权 。以Azure为例,如下图:
Let’s Encrypt实践指北

文章插图
Azure
配置好之后,过一分钟左右,利用dig命令查询一下是否生效:
$ dig-t txt_acme-challenge.your_domain.com @8.8.8.8;; OPT PSEUDOSECTION:; EDNS: version: 0, flags:; udp: 512;; QUESTION SECTION:;_acme-challenge.your_domain.com.INTXT;; ANSWER SECTION:_acme-challenge.your_domain.com. 599 INTXT"刚才那串base64编码"这里一定注意,有ANSWER SECTION才算成功,我第一次配置错了没有出来这个,但也没有注意到,于是敲回车键就挂掉了 。不过大家在实践中如果挂掉了也不要担心,重新执行命令即可 。
成功网络没什么问题的话这步就应该已经成功了,输出的信息会提示你证书生成的所在位置 。不出意外的话应该在 /etc/letsencrypt/archive/your_domain.com 下 。这里值得注意的是,LE申请的证书有效期一般都是为三个月,所以到期后需要再次申请,网上相关自动化工具一抓一大把,就不在这里赘述了 。如果遇到问题,可以继续探讨 。
Ref
  • Let’s Encrypt - FAQ (中英文)
  • Let’s Encrypt - Rate Limit (中英文)
  • Let’s Encrypt - Challenge Types (中英文)
  • Let’s Encrypt - End of Life Plan for ACMEv1
  • Certbot - Certbot-auto
  • Certbot - Getting certificates and plugins
文/ThoughtWorks朱海波

【Let’s Encrypt实践指北】


推荐阅读