「certbot」を使用して「Let’s Encrypt」で取得した証明書を削除する方法です。
certbotのバージョンについて
古いバージョンの「certbot」では証明書のデータを削除する際に、一部のデータが自動的に削除できなかったりすることがあります。
ですので、作業前に「certbot」を最新のバージョンに更新を行っておいてください。
バージョンアップ方法
「CentOS7」で「certbot」を「yum」でインストールしている場合だと下記のような感じになります。
# yum update --enablerepo=epel certbot
証明書の削除
Let’s Encryptで取得した証明を削除するには「certbot reboke」コマンドを、下記のように削除したい証明書を指定して実行します。
「xxx.xxx.xxx」の部分は削除する証明書により異なりますので適宜読み替えてください
途中で証明書を削除して良いか確認のメッセージ「(Y)es (recommended)/(N)o:」が表示されるので「y」を入力して削除を行ってください。
これで、指定した証明書がディレクトリごと削除されます。
# certbot revoke --cert-pat=/etc/letsencrypt/live/xxx.xxx.xxx/cert.pem
「conoha.server-memo.net」ように取得した証明書を削除した際の作業ログとなります。
# certbot revoke --cert-pat=/etc/letsencrypt/live/conoha.server-memo.net/cert.pem Saving debug log to /var/log/letsencrypt/letsencrypt.log Starting new HTTPS connection (1): acme-v02.api.letsencrypt.org - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Would you like to delete the cert(s) you just revoked? - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (Y)es (recommended)/(N)o: y - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Deleted all files relating to certificate conoha.server-memo.net. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Congratulations! You have successfully revoked the certificate that was located at /etc/letsencrypt/live/conoha.server-memo.net/cert.pem - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
証明書削除の確認
古いバージョンの「certbot」の場合はディレクトリが削除されない場合があるようなので念のために確認してみます。
# ls -l /etc/letsencrypt/live/ total 0 # ls -l /etc/letsencrypt/renewal total 0
「certbot certificates」コマンドを実行すると、certbotが管理している証明書の情報を表示させることが出来きます。
# certbot certificates Saving debug log to /var/log/letsencrypt/letsencrypt.log - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - No certs found. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
これで証明書が存在しないことが確認できました。
コメント