タイガーラック クリエイティブブログ
2024
May
30

【Certbot】SSL証明書更新処理の設定変更方法

今回はcertbotのrenewalディレクトリ内のconfファイルを書き換えて、証明書更新の設定を変更する方法に関して紹介していきます。

設定変更方法

let’s encryptのrenewalディレクトリに移動

cd /etc/letsencrypt/renewal

まずはletsencrypt内のrenewalディレクトリに移動。
中にはcertbot renewコマンドを行った際に読み込まれるconfファイルが入っています。証明書名はcertbot certificatesコマンドで確認できます。

証明書名の変更

mv example.com-0001.conf example.com.conf

証明書名の変更はconfファイルの変更をするだけで行なえます。
証明書を新規発行する際、登録ドメインが重複すると証明書名の後ろに-0001と付いてしまう場合がありますが、証明書を再発行しなくともconfファイル名を変更するだけで修正できます。
証明書名は証明書の削除等で特定の証明書を指定する–cert-nameコマンドで使用するので、意図しない名前で発行されてしまった場合は分かり易い名前に変更すると良いでしょう。
証明書名が変更されたかどうかはcertbot certificatesコマンドで確認できます。

プラグインの変更

vi example.com.conf

証明書発行時に指定するstandaloneやwebroot等の認証方法を変更するには、まずrenewalディレクトリ内の変更したいconfファイルを開きます。

# renew_before_expiry = 30 days
version = 1.11.0
archive_dir = /etc/letsencrypt/archive/example.com
cert = /etc/letsencrypt/live/example.com/cert.pem
privkey = /etc/letsencrypt/live/example.com/privkey.pem
chain = /etc/letsencrypt/live/example.com/chain.pem
fullchain = /etc/letsencrypt/live/example.com/fullchain.pem

# Options used in the renewal process
[renewalparams]
authenticator = webroot
account = 2j8b58gq7hsx2ag68xhvr91wjenybfls
server = https://acme-v02.api.letsencrypt.org/directory
manual_public_ip_logging_ok = None
webroot_path = /var/www/certbot/example.com, /var/www/certbot/example2.com
[[webroot_map]]
example.com = /var/www/certbot/example.com
example2.com = /var/www/certbot/example2.com

[renewalparams]の中にあるauthenticatorを変更することで、次回以降のcertbot renew時のプラグインを切り替えることが出来ます。基本的には比較的証明書の発行が容易なstandaloneから、証明書の更新時にwebサーバーを止める必要のないwebrootへ切り替えるのに使用することになるかと思います。
webrootへの切り替えの際は、

  • [renewalparams]内にwebroot_path = <証明書の認証用ディレクトリ>
  • [[webroot_map]]内に<ドメイン> = <証明書の認証用ディレクトリ>

これらの記述が必要になるので注意してください。

その他の注意点としては、これらの設定を書き換えても証明書自体の書き換えは出来ません。証明書のコモンネームの変更等をしたい場合は改めて証明書を取得し直すようにしましょう。
設定が正しく変更されたかはcertbot –dry-run renewコマンドで確認できます。

これらの書き換えを行うことで証明書の管理を行いやすくなるので、一度設定を見直してみてはいかがでしょうか?

このカテゴリの最新記事

関連記事

SHOP LIST

タイガーラック株式会社

〒577-0056
大阪府東大阪市長堂1-3-14 TOKUYASU Bld.