no-image

さくら VPS の Aipo 用 Let’s Encrypt SSL 証明書の更新

Let's Encrypt の証明書期限が近づいてきたので更新を行います。

HTTPS(TCP 443) が Web サーバ等で使われていると、そのまま更新をかけても次のようなエラーが表示されます。

Attempting to renew cert (xxxxx.example.com) from /etc/letsencrypt/renewal/xxxxx.example.com.conf produced an unexpected error: Problem binding to port 443: Could not bind to IPv4 or IPv6.. Skipping.
All renewal attempts failed. The following certs could not be renewed:
 /etc/letsencrypt/live/xxxxx.example.com/fullchain.pem (failure)

なのでまず HTTPS を使っている Aipo のサーバを停止させます。停止させる前にデータのバックアップも取っておきます。

# /usr/local/aipo/bin/backup.sh
# /usr/local/aipo/bin/shutdown.sh

初期設定時のまま特に変更することもないので、renew するだけです。Tomcat 用に Keystore 形式への変換まで行います。

# certbot renew
.....
.....
.....
# cd /etc/letsencrypt/live/aipo.example.com/
# openssl pkcs12 -export -in fullchain.pem -inkey privkey.pem -out ssl.p12
Enter Export Password: *****
Verifying - Enter Export Password: *****
# /usr/local/aipo/jre/bin/keytool -importkeystore -destkeystore tomcat.keystore -srckeystore ssl.p12 -srcstoretype PKCS12
Enter destination keystore password: #####
Re-enter new password: #####
Enter source keystore password: *****
Entry for alias 1 successfully imported.
Import command completed: 1 entries successfully imported, 0 entries failed orcancelled

後は Aipo を起動しなおすだけ。

# /usr/local/aipo/bin/startup.sh

これで終りですが、Aipo は起動してポートも開いているのに Web ブラウザからアクセスできず、かなり焦りました。とりあえず 10~15 分ほど放置したら元通りアクセスできました。

起動処理に時間がかかっているだけみたいですが、表面上は起動が完了しているように見えるので気付かないと厄介です。初期導入時にこれに気づかずに何回も再インストールしてしまい、無駄な労力をかなり使いました。

追記(2017-01-19)

証明書の期限切れが表示されたと問い合わせがあり、確認したら証明書の日付が更新されていなかった。結局初回と同じ手順でやっと更新されました。

更新(2018-03-31)

Aipo 起動スクリプトのパスが誤っていたのを修正("/usr/local/aipo/startup.sh" -> "/usr/local/aipo/bin/startup.sh")