Let’s Encrypt 在上年已經推出全網域通用憑證 (Wildcard Certificate), 也就是一張憑證可以讓網域下所有子網域通用, 所有子網域也可以使用同一張憑證。原本的網域下每個子網域都會產生一個新的憑證, 但如果網址較多管理也較麻煩, 以下紀錄一下申請 Let’s Encrypt Wildcard 憑證的方法。
網路上有很多申請 Let’s Encrypt 憑證的工具, 以下會使用 Certbot, 先執行以下指令安裝 Certbot:
-
# wget https://www.eff.org/certbot-auto
# chmod +x ./certbot-auto
# ./certbot-auto
現在可以用 Certbot 申請 Wildcard 憑證, 以下用 mydomain.com 作為例子:
-
# ./certbot-auto certonly –manual \
–preferred-challenges=dns \
–server https://acme-v02.api.letsencrypt.org/directory \
–d mydomain.com -d *.mydomain.com
然後跟著指示輸入電子郵件及回答一些問題.
最後會 Certbot 會顯示一個 TXT Record, 需要將這個 TXT Record 加入網域的 DNS Server, 以驗證網址的擁有權, 類似以下內容:
Please deploy a DNS TXT record under the name
_acme-challenge.mydomain.com with the following value:
_acme-challenge.mydomain.com with the following value:
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
將那一行很長的 TXT Record 加入 DNS Server, 完成後回到 Certbot 按 “Enter” 鍵.
如果一切正常, 那時 Wildcard 憑證便申請成功了。