開発したアプリなど一覧

Let's Encrypt を更新する際に "The client lacks sufficient authorization" と出たので対処した

アフィリエイトリンクを含む場合があります

先日ある Web サイトの SSL 証明書を更新しようとしたところ、以下のようなエラーメッセージが表示されて更新する事が出来なかった。

$ sudo certbot certonly --webroot -w /home/ryomatsu/public_html/example.com/ -d example.com Saving debug log to /var/log/letsencrypt/letsencrypt.log Plugins selected: Authenticator webroot, Installer None Cert is due for renewal, auto-renewing... Renewing an existing certificate Performing the following challenges: http-01 challenge for example.com Using the webroot path /home/ryomatsu/public_html/example.com for all unmatched domains. Waiting for verification... Cleaning up challenges Failed authorization procedure. example.com (http-01): urn:ietf:params:acme:error:unauthorized :: The client lacks sufficient authorization :: Invalid response from https://example.com/.well-known/acme-challenge/FY8qR8JWvvrpfKETJCgXBcDpZBOcUD-qzn09q64e9p4 [203.0.113.123]: "<!DOCTYPE html>\r\n<html lang=\"ja\" prefix=\"og: http://ogp.me/ns# fb: http://www.facebook.com/2008/fbml\">\r\n<head>\r\n<meta charset=\"U"

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

Domain: example.com Type: unauthorized Detail: Invalid response from https://example.com/.well-known/acme-challenge/FY8qR8JWvvrpfKETJCgXBcDpZBOcUD-qzn09q64e9p4 [203.0.113.123]: "<!DOCTYPE html>\r\n<html lang=\"ja\" prefix=\"og: http://ogp.me/ns# fb: http://www.facebook.com/2008/fbml\">\r\n<head>\r\n<meta charset=\"U"

To fix these errors, 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.

どうも Let's Encrypt の認証の際に、生成される認証用のファイルではなく何等かの HTML が表示されているようだ。試しに .well-known/acme-challenge/ に適当なファイルを作成して動作を確認してみる。

$ echo 'ok' > /home/ryomatsu/public_html/example.com/.well-known/acme-challenge/ok.txt $ ls /home/ryomatsu/public_html/example.com/.well-known/acme-challenge/ ok.txt

この状態で上記ファイルにアクセスをして確かめてみると WordPress の 404 ページが現れた。どうやら URL のルーティングが上手く動いていないようだ。

.htaccess を確認すると以下のようになっていた。

<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteRule ^.well-known/acme-challenge/(.*)$ /$1 [QSA,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule>

真ん中に "^.well-known/acme-challenge/(.*)$ /$1 [QSA,L]" という見慣れない行がある。どうやらこれが悪さをしているようだ。調査してみると WordPress 本体ではなく、"WP Encryption - One Click SSL & Force HTTPS" というプラグインがこの行を挿入しているようだ。この行を削除すると正常に Let's Encrypt を更新する事が出来た。

Sponsored Link

コメント

タイトルとURLをコピーしました