certbotの更新時にエラー
コンテンツ
certbotの証明書更新コマンドで、下記メッセージが出力しcertbot-autoが使えなくなる場合が発生しています。
Your system is not supported by certbot-auto anymore.
Certbot cannot be installed.
#certbot-auto certonly --webroot -w /var/www/public_html -d xxx.com --email xxx@example.com --debug --no-bootstrap
Upgrading certbot-auto 1.9.0 to 1.12.0...
Replacing certbot-auto...
Your system is not supported by certbot-auto anymore.
Certbot cannot be installed.
Please visit https://certbot.eff.org/ to check for other alternatives.
certbotのインストールにsnapが必要
新しいcertbotのインストールには snap が必要になりました。
yum をアップデートします。root権限で実行します。
# yum update
EPELリポジトリをインストールします
# yum install epel-release
snapdパッケージをyumコマンドでインストールします。
# yum install snapd
snapパッケージをインストールするためにはsnapdが起動しておく必要があります。そのためにsnapd.socketをアクティベーションします。
# systemctl enable --now snapd.socket
snapへのシンボリックリンクを生成します。
# ln -s /var/lib/snapd/snap /snap
snapでcertbotをインストールします。
# snap install --classic certbot
OSバージョンが古くcertbotの更新ができない
サーバーのOSバージョンが古い場合、snapもインストールができない場合があります。
# yum install snapd
Loaded plugins: fastestmirror, priorities, update-motd
Loading mirror speeds from cached hostfile
* epel: d2lzkl7pfhq30w.cloudfront.net
* epel-debuginfo: d2lzkl7pfhq30w.cloudfront.net
* epel-source: d2lzkl7pfhq30w.cloudfront.net
1067 packages excluded due to repository priority protections
No package snapd available.
Error: Nothing to do
これは対応しているEPELリポジトリにsnapが含まれていないためにエラーになります。
certbotの代替として「GetSSL」をインストール
snapがインストールできない環境ではcertbotの利用ができません。
その場合、getSSLでlet’s encrypt証明書をインストールします。
GetSSLをインストール
GetSSLをインストールします。curlでダウンロードします。
# curl --silent https://raw.githubusercontent.com/srvrco/getssl/master/getssl > getssl
# chmod 700 getssl
GetSSL設定ファイルの作成
GetSSL設定ファイルを getssl コマンドで作成します。
# ./getssl -c 証明書をインストールするドメイン名
example.comドメインの場合、下記のように記述します。
# ./getssl -c example.com
上記コマンドで、下記ファイルが作成されます。
~/.getssl
~/.getssl/getssl.cfg --GetSSLアカウントの設定ファイル
~/.getssl/example.com
~/.getssl/example.com/getssl.cfg --ドメインごとの設定ファイル
設定ファイル各種オプションの詳細は下記
https://github.com/srvrco/getssl/wiki/Config-variables
まず.getssl直下の getssl.cfg を編集します。
編集する項目は
- CA
- AGREEMENT
- ACCOUNT_EMAIL
CA="https://acme-v02.api.letsencrypt.org"
ACCOUNT_EMAIL="メッセージを取得するメールアドレス"
AGREEMENT="https://letsencrypt.org/documents/LE-SA-v1.1.1-August-1-2016.pdf"
CA(認証局)を本番サーバーに設定します。
次にドメイン直下.getsslの getssl.cfg を編集します。
編集する項目は
- CA
- ACL
CA="https://acme-v02.api.letsencrypt.org"
ACL=('/var/www/host/public_html/.well-known/acme-challenge')
ドメインのドキュメントルート直下に .well-known/acme-challenge を作成しておきます。
$ mkdir .well-known/acme-challenge
ACLには、作成した.well-known/acme-challengeまでのパスを指定します。
SSL証明書を取得
設定ファイル作成後、getsslコマンドを実行しSSL証明書を取得します。
]# ./getssl example.com
creating account key /root/.getssl/account.key
creating key - /root/.getssl/account.key
Generating RSA private key, 4096 bit long modulus
.........+++++.........++
.............++................................................................................................++
e is 65537 (0x10001)
creating key - /root/.getssl/example.com/example.com.key
Generating RSA private key, 4096 bit long modulus
.........................................++
..........++
e is 65537 (0x10001)
creating domain csr - /root/.getssl/example.com/example.com.csr
Registering account
Registered
Verify each domain
Verifying sakugol.jp
copying challenge token to /var/www/hosts/public_html/.well-known/acme-challenge/DGXXXXXXXX_Y7pxxxxxxxxxxxxxxxxkCsA
sending request to ACME server saying we're ready for challenge
checking if challenge is complete
Verified example.com
Verification completed, obtaining certificate.
Requesting Finalize Link
Requesting Order Link
Requesting certificate
Certificate saved in /root/.getssl/example.com/example.com.crt
/root/.getssl/example.com/example.com.crt didn't match server
getssl: example.com - rsa certificate obtained but certificate on server is different from the new certificate
最後の行
getssl: example.com – rsa certificate obtained but certificate on server is different from the new certificate
これはまだWebサーバー側が未設定のためのメッセージになります。
上記コマンドで、~/.getssl/ドメインディレクトリに証明書が作成されます。
作成された証明書をWebサーバー側に反映させ、Webサーバーを再起動で証明書が切り替わります。
参考サイト
centos6を使っているので、とても参考になりました!
単一ドメインではうまくSSL化できたのですが、下記のような複数サブドメインの場合はどのように設定したらいいのでしょうか。
example.com
sp.example.com
i.example.com