介紹如何使用 certbot 指令刪除由 Let’s Encrypt 頒發的網域 SSL 憑證。
在使用
certbot 設定好網域的 SSL 憑證之後,系統就會自動定期更新憑證,而當網站要下線時,也要記得以 certbot 指令將對應的網域 SSL 憑證刪除,以下是操作步驟。
確認網域名稱
所有透過 certbot 取得 SSL 憑證的網域,都會有對應的設定檔案放在 /etc/letsencrypt/renewal/ 目錄下,所以從目錄中的設定檔就可以查看目前所有的網域名稱:
# 列出 certbot 所有網域設定檔
ls /etc/letsencrypt/renewal/
officeguide.cc.conf another.domain.tw.conf
只要將設定檔名稱結尾的 .conf 去掉,就是對應的網域名稱,例如 another.domain.tw.conf 設定檔就對應 another.domain.tw 這個網域。
撤銷網域 SSL 憑證
使用 certbot 搭配 revoke 指令撤銷網域 SSL 憑證,憑證的位置通常放在 /etc/letsencrypt/live/網域名稱/cert.pem,例如撤銷 my.domain.tw 網域 SSL 憑證:
# 撤銷 my.domain.tw 網域 SSL 憑證 certbot revoke --cert-path /etc/letsencrypt/live/my.domain.tw/cert.pem
刪除網域 SSL 憑證與相關設定
將憑證撤銷之後,就可以使用 certbot 搭配 delete 指令刪除沒用的網域 SSL 憑證與相關設定:
# 刪除 my.domain.tw 網域 SSL 憑證與相關設定 sudo certbot delete --cert-name my.domain.tw
參考資料:BrilliantCode.net

