3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Let's Encryptの"certbot renew"で「Connection refused. Skipping.」が出たときの対処法

Posted at

環境

  • Conoha VPS(1GB)
  • CentOS 7.6
  • Certbot 0.31.0-2.el7 (yumで入れた記憶...)
  • Apache 2.4.6

事象

certbot renewコマンドを実行すると、証明書の更新に失敗する。

Console
$ sudo certbot renew
...(略)...
Attempting to renew cert ([ドメイン名]) from /etc/letsencrypt/renewal/[ドメイン名].conf produced an unexpected error: Failed authorization procedure. [ドメイン名] (http-01): urn:ietf:params:acme:error:connection :: The server could not connect to the client to verify the domain :: Fetching http://[ドメイン名]/.well-known/acme-challenge/[乱数]: Connection refused. Skipping.
All renewal attempts failed. The following certs could not be renewed:
  /etc/letsencrypt/live/[ドメイン名]/fullchain.pem (failure)
1 renew failure(s), 0 parse failure(s)

原因

  • Apacheで「mod_writeを使い、HTTPで来たすべての接続をHTTPSへリダイレクトする」設定をしていた。
  • Let's Encryptのドメイン所有者確認は「http://[ドメイン名]/.well-known/acme-challenge/*」が対象となっているが、全て「https」へリダイレクトされてしまった。
  • よってLet's Encrypt的にはドメイン所有者確認ができず、更新に失敗した。

対応

「/.well-known/acme-challenge/*」へのアクセスはHTTPSへリダレクトしない設定とした。

httpd.conf(対応前)
...(略)...
<VirtualHost *:80>
  DocumentRoot /var/www/html
  ServerName [ドメイン名]

  <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{HTTPS} off
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
  </IfModule>
</VirtualHost>
...(略)...
追加設定
RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge/*
httpd.conf(対応後)
...(略)...
<VirtualHost *:80>
  DocumentRoot /var/www/html
  ServerName [ドメイン名]

  <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge/*
    RewriteCond %{HTTPS} off
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
  </IfModule>
</VirtualHost>
...(略)...
3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?