2020
19
Feb

IT技術

サーバ証明書の更新ではまった話

ポートフォリオをチェックしようとしたら、証明書が無効となっていた。
そういえば有効期限が1か月前だと警告メールが来ていた。

普段はcronで証明書を自動更新しているつもりだったので、気にしていなかったのだが、証明書更新が動作していないかったようだ。

何が問題だったのか、そもそもどうやって構築したのか、いろいろと仕様を忘れていたので、備忘録としてブログに残そうと思う。

まずはcertbotの新リビジョンが出ていたので更新をかける。

[root@alpha ~]# yum update certbot
================================================================================
 Package                 Arch           Version              Repository    Size
================================================================================
Updating:
 certbot                 noarch         1.0.0-1.el7          epel          41 k

次に証明書を更新する。

[root@alpha ~]# /usr/bin/certbot renew
・・・(中略)・・・
Cert is due for renewal, auto-renewing...
Using the webroot path /var/www/html for all unmatched domains.
Waiting for verification...
Challenge failed for domain www.sigezo.online
http-01 challenge for www.sigezo.online
Cleaning up challenges
Attempting to renew cert (www.sigezo.online) from /(pathは秘密)/www.sigezo.online.conf produced an unexpected error: Some challenges have failed.. Skipping.
All renewal attempts failed. The following certs could not be renewed:
/(pathは秘密)/www.sigezo.online/fullchain.pem (failure)

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

All renewal attempts failed. The following certs could not be renewed:
/(pathは秘密)/www.sigezo.online/fullchain.pem (failure)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1 renew failure(s), 0 parse failure(s)

IMPORTANT NOTES:
- The following errors were reported by the server:

Domain: www.sigezo.online
Type: unauthorized
Detail: Invalid response from
http://www.sigezo.online/.well-known/acme-challenge/(ハッシュは秘密)
[118.27.1.65]: "<!DOCTYPE html>\n<html lang=\"ja\">\n<head
prefix=\"og: http://ogp.me/ns# fb: http://ogp.me/ns/fb#\">\n\t<meta
charset=\"UTF-8\">\n\t<meta n"

To fix one error, please make sure that your domain name was
entered correctly and the DNS A/AAAA record(s) for that domain
contain(s) the right IP address.

エラーが表示された。
どうやらcertbotは更新の際、サーバの存在確認の為、サーバに埋め込まれたハッシュ情報をhttpで参照しようとして、無効な応答のためエラーを吐いたらしい。

Domain: www.sigezo.online
Type: unauthorized
Detail: Invalid response from
http://www.sigezo.online/.well-known/acme-challenge/(ハッシュは秘密)

wordpressを構築した際にhttpdの設定でDocumentRootをWordpressディレクトリに変更したことを思い出したので変更する。

vi /etc/httpd/conf/httpd.conf
 ・・・(中略)・・・
DocumentRoot "/var/www/wordpress"
  ↓
DocumentRoot "/var/www/html"

httpdを再起動し、設定を反映させる。

# systemctl restart httpd.service

再度、証明書更新を行う。

# /usr/bin/certbot renew
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
Performing the following challenges:
http-01 challenge for www.sigezo.online
Using the webroot path /var/www/html for all unmatched domains.
Waiting for verification...
Cleaning up challenges

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
new certificate deployed without reload, fullchain is
/(pathは秘密)/www.sigezo.online/fullchain.pem
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Congratulations, all renewals succeeded. The following certs have been renewed:
  /(pathは秘密)/www.sigezo.online/fullchain.pem (success)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

証明書の更新は成功したようだ。

ブラウザでhttpsにアクセスし、証明書のエラーが出ないことを確認。

このままではwordpressが閲覧できないので設定を元に戻しておく、

vi /etc/httpd/conf/httpd.conf
 ・・・(中略)・・・
DocumentRoot "/var/www/html"
  ↓
DocumentRoot "/var/www/wordpress"

httpdを再起動し、設定を反映させる。

# systemctl restart httpd.service

とりあえず手動での更新方法はここまで。
自動更新の修正については、また後日対策を考えたい。

 

コメント

  1. この記事へのコメントはありません。

  1. この記事へのトラックバックはありません。