Let’s Encryptのトラブルシューティング

let's encrypt logo

今回は、無料でSSL認証を導入できる Let’s Encrypt の認証キーを更新する際に起こるエラーについて調べました。

Let’s Encryptで認証キーの更新コマンド(certbot renew)を入力したら下記のようなエラーが出ました。

Let’s Encryptは無料のSSL認証キーがもらえる便利なサービスですが、無料なだけに3ヶ月に1回キーの更新をしなければなりません。そこでいつも通り「certbot renew」コマンドを使ってすべてのドメインを更新しようとしたところ・・・1つのドメインで、下記のようなエラーメッセージが出てしまいました。

Attempting to renew cert (www.xxxxxxxx.com) from /etc/letsencrypt/renewal/www .xxxxxxx.com.conf produced an unexpected error: Some challenges have failed. . Skipping.
.xxxxxxx.com.conf produced an unexpected error: Some challenges have failed.

それではということでマニュアルで更新を試す

しょうがないので、Googleでいろいろ調べて、マニュアルモードで更新をかけてみることにしました。

certbot certonly --manual -d {ドメイン名}

【設定例】

certbot certonly --server https://acme-v02.api.letsencrypt.org/directory -d www.xxxxxxx.com --manual --preferred-challenges dns-01

すると、また別のエラーが・・・

コマンドを投入しても赤い字でエラーが出ます。
念の為に、コマンドを入れた時の表示を詳しく見てみると、以下のような記述が出ており、それを無視して続行したためにエラーになっていました・・・

Please deploy a DNS TXT record under the name
_acme-challenge.www.xxxxxxx.com with the following value:

rM5fnLRaCqG5pa5HGEpkXsjI5EF9JyU2Bs7w9ErvKXQ

Before continuing, verify the record is deployed.

これは、DNSのTXTレコードに指定された文字列を入れろという指示です。この文字列は、certbot コマンドを入れる度に変わりますので注意が必要です。この表示が出たら、それ以上進まないで、ここでご自分のドメインのDNSレコードを編集する画面を開きます。GoDaddyの場合は、自分の持っているドメインの一覧から、DNSメニューのDNSを選択すれば、DNSレコードを編集する画面を選べます。

GoDaddyのDNSマネージャでの設定方法

post-052-img-0001

DNSレコードの編集画面で、TXTレコードを追加します。もしも、指示が、「_acme-challenge.www.xxxxxxx.com」のようにwwwを含んでいる場合、DNSのTXTレコードのHOSTの部分には、「_acme-challenge.www」を設定します。こうしないと認証が通りませんでした。もしも、「_acme-challenge.xxxxxxx.com」のようにwwwを含んでいない場合は、TXTレコードのHOST部分には、「_acme-challenge」とだけ入力します。

DNSの設定ができたらコマンドをすすめる

多分、ENTERキーを押せという指示のところで止まっていたと思いますので、DNSレコードの編集ができたらまず、下記のサイトでDNSレコードにちゃんとTXTレコードが追加されたかどうかを確かめます。
https://mxtoolbox.com/SuperTool.aspx

最終的に

最終的に、「 – Congratulations! Your certificate and chain have been saved at:」というメッセージが出れば更新完了です!

エラーを出しすぎるとブロックされる

Let’s Encryptでは、certbotなどのコマンドで1時間に5回以上認証エラーを出すと、1時間だけコマンドの入力ができなくなります。

An unexpected error occurred:
There were too many requests of a given type :: Error creating new order :: too many failed authorizations recently: see https://letsencrypt.org/docs/rate-limits/

制限事項の詳細を読んでおこう

あれこれいじくっていて、このメッセージがでてしまったら、少し休んでからまた作業しなおしましょう。他にもいろいろな制限があるみたいなので、一度下記のページを読んでおくことをお勧めします。
https://letsencrypt.org/docs/rate-limits/

更新時のエラー

ステップ1

autoで更新ができない場合、以下のコマンドを投入します。

certbot certonly --manual -d {ドメイン名}

すると、以下のような表示が出ますので「y」を押下します。

Are you OK with your IP being logged?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: y

すると、以下のような指示が出ます。

Create a file containing just this data

《文字の羅列1》

And make it available on your web server at this URL:
http://www.ドメイン名.com/.well-known/acme-challenge/《文字の羅列2》
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Press Enter to Continue

ここで、ENTERキーを押さないで、以下の作業をします。

  1. フォルダを作成する
    DocumentRoot以下に「.well-known/acme-challenge」というフォルを作ります。例えば、DocumentRootが「/homne/htdocs/www」だとすると、「/homne/htdocs/www/.well-known/acme-challenge」となります。
  2. フォルダ内にファイルを作る
    上記1で作ったフォルダ内に、次のようなファイルを作成します。「/homne/htdocs/www/.well-known/acme-challenge/《文の羅列2》」そのファイルの中に、《文字の羅列1》を書き込んで保存します。
  3. ファイルをHTTP:80でアクセスできるようにする
    /etc/httpd/conf/httpd.confを編集して、「/homne/htdocs/www/.well-known/acme-challenge/《文の羅列2》」が、HTTP(ポート番号:80)でアクセスできるようにします。httpd.confを編集したらWEBサーバを再起動します。
  4. ENTERキーを押下する
    上のスクリプトで、「Press Enter to Continue」のところで、ENTERキーを押下して処理を進めます。赤い色のエラー文が出なければ成功です。次のステップに進みます。

ステップ2

ステップ1の処理が成功したら、次のステップに進みます。

certbot -d ドメイン名.com -d www.ドメイン名.com

このコマンドを投入すると、以下の表示が出ます。

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache
Starting new HTTPS connection (1): acme-v02.api.letsencrypt.org
Cert not yet due for renewal

You have an existing certificate that has exactly the same domains or certificate name you requested and isn't close to expiry.
(ref: /etc/letsencrypt/renewal/www.diving-team.com.conf)

What would you like to do?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: Attempt to reinstall this existing certificate
2: Renew & replace the cert (limit ~5 per 7 days)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2

1は既存の認証を再インストール、2は更新です。
すると、次に以下のような表示が出ます。

Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 1

1は、設定を変更しない。2はHTTPSアクセスのみに限定する変更をhttpd設定に加える。今回は1を選択しました。すると、以下のような赤いメッセージが出ますが、問題ありません。

Future versions of Certbot will automatically configure the webserver so that all requests redirect to secure HTTPS access. You can control this behavior and disable this warning with the --redirect and --no-redirect flags.

最後に、必要であればHTTP(80)でアクセスできるようにしていた設定を削除します。

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