近幾年我的網域憑證一直都用Letsencrypt

比較麻煩的地方是每三個月都要驗證一次

記錄一下,不然每次都要去Google找解法

如果是新安裝的要記得先新增repository跟安裝certbot

    ~$ add-apt-repository ppa:certbot/certbot

    ~$ apt update && apt install certbot

接著要來下指令跑申請流程了

~# certbot certonly --manual -d *.example.com -d example.com --agree-tos --no-bootstrap --manual-public-ip-logging-ok --preferred-challenges dns-01 --server https://acme-v02.api.letsencrypt.org/directory

沒意外應該會跑出類似下面的情況

    Saving debug log to /var/log/letsencrypt/letsencrypt.log
    Plugins selected: Authenticator manual, Installer None
    Obtaining a new certificate
    Performing the following challenges:
    dns-01 challenge for example.com
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Please deploy a DNS TXT record under the name
    _acme-challenge.example.com with the following value:
    sdsdfj2812121m2n1nsmnsmnxzmxnzmxnzmxnzmxnzmxnzmxzx
    Before continuing, verify the record is deployed.
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
    Press Enter to Continue

這個地方是要做DNS的驗證,證明你是這個網域的主人,像我自己就有架設DNS Server,所以可以很快速的完成這個動作

如果是使用domain 提供業者的DNS代管服務,請記得等一段時間確定可以用dig解到之後再按Enter喔,因為

一按下去就會去驗證了

一按下去就會去驗證了

一按下去就會去驗證了

當按下Enter驗證後,沒意外他就會從外面解到剛剛的TXT Record,接著就會出現類似下方的畫面

    Press Enter to Continue
    Waiting for verification...
    Cleaning up challenges
    IMPORTANT NOTES:
    - Congratulations! Your certificate and chain have been saved at:
    /etc/letsencrypt/live/example.com/fullchain.pem
    Your key file has been saved at:
    /etc/letsencrypt/live/example.com/privkey.pem
    Your cert will expire on 2019-02-27. To obtain a new or tweaked
    version of this certificate in the future, simply run certbot
    again. To non-interactively renew *all* of your certificates, run
    "certbot renew"
    - If you like Certbot, please consider supporting our work by:
    Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
    Donating to EFF:                    https://eff.org/donate-le

這樣子一來就算完成了Domain Wildcard的憑證驗證了

放置憑證的位子在/etc/letsencrypt/live/example.com/底下

通常裡面會有四個pem檔案跟一個README,其中有個fullchain.pem其實就是其他三個pem的合體,但在某些地方(e.g. ACM)就會需要一個個填寫

本來有想要接著做自動化,但因為需要外掛去寫DNS Server,就沒嘗試了…未來心血來潮的話再來測試

Ref medium