[Time4VPS] FileMaker Server の Let’s Encrypt 証明書の更新

以前 Time4VPS の FileMaker で、Let’s Encrypt 証明書の更新について書いた。

Time4VPS に FileMaker Server を構築する4 – with a Christian Wife
https://wacw.cf/2021/07/04/filemaker-server-on-time4vps-4/

あのときは、–force-renew による強制更新だった。

そして実際の更新期間になったので、さっそく通常の更新をしてみることにした。

環境:
・Time4VPS「Linux 8」(CPU: 2 x 2.60 GHz、RAM: 8192 MB、Storage: 80 GB、Bandwidth: 8 TB、Port speed: 100 Mbps、Virtualization: KVM)、CentOS 7.8
・FileMaker Server for Linux 19.0.1.22(英語)
・macOS Catalina Version 10.15.6(英語環境) で SSH 接続
・Freenom のドメイン(サブドメイン)

(1)Time4VPS に SSH で root でログインする。

$ ssh [ホスト名(〜.time4vps.cloud)] -l root

(2)現在の更新期限を確認する。

# certbot certificates
Saving debug log to /var/log/letsencrypt/letsencrypt.log

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Found the following certs:
  Certificate Name: [ドメイン名]
	Serial Number: [シリアル番号]
	Key Type: RSA
	Domains: [ドメイン名]
	Expiry Date: 2021-08-23 23:54:03+00:00 (VALID: 28 days)
	Certificate Path: /etc/letsencrypt/live/[ドメイン名]/fullchain.pem
	Private Key Path: /etc/letsencrypt/live/[ドメイン名]/privkey.pem
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

更新期限が 2021 年8月 23 日だと分かった。30 日を切っているので更新できる。

(2)【FileMaker Server に登録されている現在の証明書を削除】

2つの方法があるが、今回は方法2で行った。

(方法1)FileMaker Server の Admin Console で、「Configuration>SSL Certificate>Delete Files」をクリック。

(方法2)以下のコマンドを実行する。

証明書を削除する。

# fmsadmin certificate delete

ファイルを閉じ、FileMaker Server を再起動する。

$ fmsadmin close -y -u [ユーザー名] -p [パスワード]
$ fmsadmin restart server

FileMaker Server の Admin Console で、「Configuration>SSL Certificate」を確認すると、証明書がデフォルトの Claris のものになっているはずだ。

(3)【Let’s Encrypt の証明書を更新する】

(3-1)–dry-run オプションで実行して実験してみる。

# certbot renew --dry-run
Saving debug log to /var/log/letsencrypt/letsencrypt.log

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing /etc/letsencrypt/renewal/[ドメイン名].conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cert is due for renewal, auto-renewing...
Plugins selected: Authenticator webroot, Installer None
Starting new HTTPS connection (1): acme-staging-v02.api.letsencrypt.org
Simulating renewal of an existing certificate for [ドメイン名]
Performing the following challenges:
http-01 challenge for [ドメイン名]
Using the webroot path /opt/FileMaker/FileMaker Server/HTTPServer/htdocs for all unmatched domains.
Waiting for verification...
Cleaning up challenges

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
new certificate deployed without reload, fullchain is
/etc/letsencrypt/live/[ドメイン名]/fullchain.pem
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations, all simulated renewals succeeded: 
  /etc/letsencrypt/live/[ドメイン名]/fullchain.pem (success)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Congratulations と表示されたので、成功したようだ。

(3-2)実際に更新してみる。

# certbot renew
Saving debug log to /var/log/letsencrypt/letsencrypt.log

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing /etc/letsencrypt/renewal/[ドメイン名].conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cert is due for renewal, auto-renewing...
Plugins selected: Authenticator webroot, Installer None
Starting new HTTPS connection (1): acme-v02.api.letsencrypt.org
Renewing an existing certificate for [ドメイン名]
Performing the following challenges:
http-01 challenge for [ドメイン名]
Using the webroot path /opt/FileMaker/FileMaker Server/HTTPServer/htdocs for all unmatched domains.
Waiting for verification...
Cleaning up challenges

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
new certificate deployed without reload, fullchain is
/etc/letsencrypt/live/[ドメイン名]/fullchain.pem
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations, all renewals succeeded: 
  /etc/letsencrypt/live/[ドメイン名]/fullchain.pem (success)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Congratulations と表示されたので成功だ。

(3-3)有効期限が伸びたかどうかを調べる。

# certbot certificates
Saving debug log to /var/log/letsencrypt/letsencrypt.log

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Found the following certs:
  Certificate Name: [ドメイン名]
	Serial Number: [シリアル番号]
	Key Type: RSA
	Domains: [ドメイン名]
	Expiry Date: 2021-10-24 02:36:15+00:00 (VALID: 89 days)
	Certificate Path: /etc/letsencrypt/live/[ドメイン名]/fullchain.pem
	Private Key Path: /etc/letsencrypt/live/[ドメイン名]/privkey.pem
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

残り 89 日になった。更新すると、有効期限からプラス 90 日になるのではなく、更新日からプラス 90 日になるようだ。有効期限まで 30 日を切ったら更新することにしたので、60 日ごとに作業をすることになるわけだ。

(4)/etc/letsencrypt/live/[ドメイン名]/ に保存された証明書(cert.pem、chain.pem、privkey.pem)を FileMaker Server のディレクトリ(/opt/FileMaker/FileMaker Server/CStore)にコピーする。上書き確認があるので y で上書きする。

# cp /etc/letsencrypt/live/[ドメイン名]/cert.pem /etc/letsencrypt/live/[ドメイン名]/chain.pem /etc/letsencrypt/live/[ドメイン名]/privkey.pem /opt/FileMaker/FileMaker\ Server/CStore/

(5)証明書を FileMaker Server にインポートする。

# fmsadmin certificate import /opt/FileMaker/FileMaker\ Server/CStore/cert.pem --keyfile /opt/FileMaker/FileMaker\ Server/CStore/privkey.pem --intermediateCA /opt/FileMaker/FileMaker\ Server/CStore/chain.pem

(6)FileMaker Serverを再起動する。

# fmsadmin close -y -u [ユーザー名] -p [パスワード]
# fmsadmin restart server -u [ユーザー名] -p [パスワード]

(7)FileMaker Server Admin Console で「Configuration>SSL Certificate」が Let’s Encrypt のものになり、有効期限も更新されていることを確認する。

(8)CentOS を再起動。

# fmsadmin close -y -u [ユーザー名] -p [パスワード]
# fmsadmin stop server -u [ユーザー名] -p [パスワード]
# reboot

再起動後、FileMaker Server Admin Console にアクセスし、ブラウザで証明書情報を確認すると、こちらも新しい Let’s Encrypt の証明書になっているはずだ。

参考:
Time4VPS に FileMaker Server を構築する3 – with a Christian Wife
https://wacw.cf/2021/07/03/filemaker-server-on-time4vps-3/

CentOS6, CentOS7 システムコマンド対応表
https://www.upken.jp/kb/cent6-cent7.htmlq