CentOS7 用 letsencrypt 簽 Wildcard SSL 憑證

先安裝 certbot

# yum install epel-release -y
# yum-config-manager –enable rhui-REGION-rhel-server-extras rhui-REGION-rhel-server-optional
# yum install certbot python2-certbot-apache -y

然後簽署你要的網域,下列指令要在 dns server 上面執行

# certbot certonly –manual -d “*.liho.tw” -d “liho.tw” –preferred-challenges dns-01 –server https://acme-v02.api.letsencrypt.org/directory

它會要求在 dns 上面加入一筆 txt 紀錄

Please deploy a DNS TXT record under the name
_acme-challenge.liho.tw with the following value:

qp3obE4Uv1Ih6dnamzyh0zSQYgDilL1x9x2T4VmKiMI

按照指示,在dns裡面加入下列一行

_acme-challenge.liho.tw. IN TXT “qp3obE4Uv1Ih6dnamzyh0zSQYgDilL1x9x2T4VmKiMI”

然後重新啟動 dns server

# systemctl restart named

並確認是否設定好 txt 紀錄

# dig -t txt _acme-challenge.liho.tw @8.8.4.4

如果 dns 紀錄可以被查詢得到,就可以回到 certbot 那個指令繼續驗證。

驗證好了之後,在下列路徑找 ssl 憑證

# /etc/letsencrypt/live/liho.tw/fullchain.pem
# /etc/letsencrypt/live/liho.tw/privkey.pem

記得設定 crontab 方便下次自己簽署 ssl 憑證

# vi /etc/crontab
0 0,12 * * * root python -c ‘import random; import time; time.sleep(random.random() * 3600)’ && /usr/bin/certbot renew

完成~

Leave a Reply

Your email address will not be published. Required fields are marked *

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.