質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
CentOS

CentOSは、主にRed Hat Enterprise Linux(RHEL)をベースにした、フリーのソフトウェアオペレーティングシステムです。

SSL

SSL(Secure Sockets Layer)とは、暗号化されたプロトコルで、インターネット上での通信セキュリティを提供しています。

EC-CUBE

EC-CUBEは、主に日本国内で開発されているECコンテンツ管理システムです。ロックオン社のECKitを元にしてオープンソース化され、商品管理・受注管理・顧客管理・売上集計などECに特化した様々な機能を備えています。

Q&A

解決済

1回答

3581閲覧

centos7(ECCUBE4系利用)にてlet's encryptの手動更新ができずに困っています。

okubo

総合スコア18

CentOS

CentOSは、主にRed Hat Enterprise Linux(RHEL)をベースにした、フリーのソフトウェアオペレーティングシステムです。

SSL

SSL(Secure Sockets Layer)とは、暗号化されたプロトコルで、インターネット上での通信セキュリティを提供しています。

EC-CUBE

EC-CUBEは、主に日本国内で開発されているECコンテンツ管理システムです。ロックオン社のECKitを元にしてオープンソース化され、商品管理・受注管理・顧客管理・売上集計などECに特化した様々な機能を備えています。

0グッド

0クリップ

投稿2020/01/20 07:52

編集2020/01/22 02:36

前提・実現したいこと

サーバは初心者ですが、VPSを使ってショッピングサイトを作成することとなりました。
周りに質問できる人もおらず、ネットで調べるばかりでしたが、今回どうしてもわからなかったため、
ご質問させていただきます。

やったこと

  • さくらインターネットのVPSにてcentos7をインストール
  • httpd(apache)インストール
  • 下記ページを参考にlet's encryptでSSL化

 https://centossrv.com/apache-certbot.shtml

  • 80,443ポートは開放
  • EC-CUBE4.0.3をインストール

このSSLが更新期限が近付いており、更新したいのが
実現したいこととなります。

発生している問題・エラーメッセージ

手動にて

certbot renew --dry-run

のコマンドをしたところ下記のようなエラーになります。

IMPORTANT NOTES:

  • The following errors were reported by the server:

    Domain: 〇〇〇〇〇.com
    Type: unauthorized
    Detail: Invalid response from
    http://〇〇〇〇〇.com/.well-known/acme-challenge/nCiT5mmOC_PxQKCItWx21v-q7_iW5Tv_q4VQiWA35yo
    [〇〇〇.〇〇.〇〇.〇〇〇]: "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n<html><head>\n<title>404 Not
    Found</title>\n</head><body>\n<h1>Not Found</h1>\n<p"

    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.

また、エラーログを見ると下記のようなログがありました。

2020-01-20 15:48:23,693:DEBUG:acme.client:JWS payload:

2020-01-20 15:48:23,695:DEBUG:acme.client:Sending POST request to https://acme-staging-v02.api.letsencrypt.org/acme/authz-v3/33853098:
{
"protected": "eyJub25jZSI6ICIwMDAyQ0g5ZndvNkM0RUZFYVUtSWs4VVlkMThRY3VrdkFPYmpsRVFPcDkwMCIsICJ1cmwiOiAiaHR0cHM6Ly9hY21lLXN0YWdpbmctdjAyLmFwaS5sZXRzZW5jcnlwdC5vcmcvYWNtZS9hdXRei1y8zMzg1MzA5OCIsICJraWQiOiAiaHR0cHM6Ly9hY21lLXN0YWdpbmctdjAyLmFwaS5sZXRzZW5jcnlwdC5vcmcvYWNtZS9hY2N0LzEyMTQ4NzU0IiwgImFsZyI6ICJSUzI1NiJ9",
"payload": "",
"signature": "RemLZK7c5IeTLufxRaVD_vZexwXCJqHUhiNBl8um3oXa4Z0m3C4ltz_YmXVPk5M_IOhYi-sSkr4MZbKFXHrgrKRxGgBjO4tovQoKLbQQ8nFCrW7g52SC7G8Jmk3-qMHeK8lXrnWSNeN3iE5wDts87LzGKesuWZaE2VU_VCEicHyaknhODujs50rtv1iL2OAlhQsPKyL3sGpAxD8krrOMvyJ2vcspNMk_9uBfhrNezQC8cG_IxR7zg7i5cuwhZeL9Kx6w93ZXyFi9NzYYUqwNbZUsI75Ih9YywgqX_hawQ9-nz0GgkwVB1RWH4SThl02e824nNWkv6RkR9OQ"
}
2020-01-20 15:48:23,848:DEBUG:requests.packages.urllib3.connectionpool:"POST /acme/authz-v3/33853098 HTTP/1.1" 200 1222
2020-01-20 15:48:23,849:DEBUG:acme.client:Received response:
HTTP 200
content-length: 1222
cache-control: public, max-age=0, no-cache
strict-transport-security: max-age=604800
server: nginx
connection: keep-alive
link: https://acme-staging-v02.api.letsencrypt.org/directory;rel="index"
boulder-requester: 12148754
date: Mon, 20 Jan 2020 06:48:23 GMT
x-frame-options: DENY
content-type: application/json
replay-nonce: 0002HhNqVYZGLM5ECh72cmqO-nbAdi_YJamL7Vpwcdm8Tdo

{
"identifier": {
"type": "dns",
"value": "〇〇〇〇〇.com"
},
"status": "invalid",
"expires": "2020-01-27T06:48:22Z",
"challenges": [
{
"type": "http-01",
"status": "invalid",
"error": {
"type": "urn:ietf:params:acme:error:unauthorized",
"detail": "Invalid response from http://〇〇〇〇〇.com/.well-known/acme-challenge/nCiT5mmOC_PxQKCItWx21v-q7_iW5Tv_q4VQiWA35yo [〇〇〇.〇〇.〇〇.〇〇〇]: "\u003c!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\"\u003e\n\u003chtml\u003e\u003chead\u003e\n\u003ctitle\u003e404 Not Found\u003c/title\u003e\n\u003c/head\u003e\u003cbody\u003e\n\u003ch1\u003eNot Found\u003c/h1\u003e\n\u003cp"",
"status": 403
},
"url": "https://acme-staging-v02.api.letsencrypt.org/acme/chall-v3/33853098/q0tq3w",
"token": "nCiT5mmOC_PxQKCItWx21v-q7_iW5Tv_q4VQiWA35yo",
"validationRecord": [
{
"url": "http://〇〇〇〇〇.com/.well-known/acme-challenge/nCiT5mmOC_PxQKCItWx21v-q7_iW5Tv_q4VQiWA35yo",
"hostname": "〇〇〇〇〇.com",
"port": "80",
"addressesResolved": [
"〇〇〇.〇〇.〇〇.〇〇〇"
],
"addressUsed": "〇〇〇.〇〇.〇〇.〇〇〇"
}
]
}
]
}
2020-01-20 15:48:23,849:DEBUG:acme.client:Storing nonce: 0002HhNqVYZGLM5ECh72cmqO-nbAdi_YJamL7Vpwcdm8Tdo
2020-01-20 15:48:23,850:WARNING:certbot.auth_handler:Challenge failed for domain 〇〇〇〇〇.com
2020-01-20 15:48:23,850:INFO:certbot.auth_handler:http-01 challenge for 〇〇〇〇〇.com
2020-01-20 15:48:23,850:DEBUG:certbot.reporter:Reporting to user: The following errors were reported by the server:

Domain: 〇〇〇〇〇.com
Type: unauthorized
Detail: Invalid response from http://〇〇〇〇〇.com/.well-known/acme-challenge/nCiT5mmOC_PxQKCItWx21v-q7_iW5Tv_q4VQiWA35yo [〇〇〇.〇〇.〇〇.〇〇〇]: "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n<html><head>\n<title>404 Not Found</title>\n</head><body>\n<h1>Not Found</h1>\n<p"

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.
2020-01-20 15:48:23,851:DEBUG:certbot.error_handler:Encountered exception:
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/certbot/auth_handler.py", line 90, in handle_authorizations
self._poll_authorizations(authzrs, max_retries, best_effort)
File "/usr/lib/python2.7/site-packages/certbot/auth_handler.py", line 154, in _poll_authorizations
raise errors.AuthorizationError('Some challenges have failed.')
AuthorizationError: Some challenges have failed.

2020-01-20 15:48:23,851:DEBUG:certbot.error_handler:Calling registered functions
2020-01-20 15:48:23,851:INFO:certbot.auth_handler:Cleaning up challenges
2020-01-20 15:48:23,851:DEBUG:certbot.plugins.webroot:Removing /var/www/html/.well-known/acme-challenge/nCiT5mmOC_PxQKCItWx21v-q7_iW5Tv_q4VQiWA35yo
2020-01-20 15:48:23,852:DEBUG:certbot.plugins.webroot:All challenges cleaned up
2020-01-20 15:48:23,852:WARNING:certbot.renewal:Attempting to renew cert (〇〇〇〇〇.com) from /etc/letsencrypt/renewal/〇〇〇〇〇.com.conf produced an unexpected error: Some challenges have failed.. Skipping.
2020-01-20 15:48:23,853:DEBUG:certbot.renewal:Traceback was:
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/certbot/renewal.py", line 449, in handle_renewal_request
main.renew_cert(lineage_config, plugins, renewal_candidate)
File "/usr/lib/python2.7/site-packages/certbot/main.py", line 1208, in renew_cert
renewed_lineage = _get_and_save_cert(le_client, config, lineage=lineage)
File "/usr/lib/python2.7/site-packages/certbot/main.py", line 116, in _get_and_save_cert
renewal.renew_cert(config, domains, le_client, lineage)
File "/usr/lib/python2.7/site-packages/certbot/renewal.py", line 307, in renew_cert
new_cert, new_chain, new_key, _ = le_client.obtain_certificate(domains, new_key)
File "/usr/lib/python2.7/site-packages/certbot/client.py", line 348, in obtain_certificate
orderr = self._get_order_and_authorizations(csr.data, self.config.allow_subset_of_names)
File "/usr/lib/python2.7/site-packages/certbot/client.py", line 384, in _get_order_and_authorizations
authzr = self.auth_handler.handle_authorizations(orderr, best_effort)
File "/usr/lib/python2.7/site-packages/certbot/auth_handler.py", line 90, in handle_authorizations
self._poll_authorizations(authzrs, max_retries, best_effort)
File "/usr/lib/python2.7/site-packages/certbot/auth_handler.py", line 154, in _poll_authorizations
raise errors.AuthorizationError('Some challenges have failed.')
AuthorizationError: Some challenges have failed.

2020-01-20 15:48:23,854:ERROR:certbot.renewal:The following certs could not be renewed:
2020-01-20 15:48:23,854:ERROR:certbot.renewal: /etc/letsencrypt/live/〇〇〇〇〇.com/fullchain.pem (failure)
2020-01-20 15:48:23,855:DEBUG:certbot.log:Exiting abnormally:
Traceback (most recent call last):
File "/bin/certbot", line 9, in <module>
load_entry_point('certbot==0.38.0', 'console_scripts', 'certbot')()
File "/usr/lib/python2.7/site-packages/certbot/main.py", line 1378, in main
return config.func(config, plugins)
File "/usr/lib/python2.7/site-packages/certbot/main.py", line 1287, in renew
renewal.handle_renewal_request(config)
File "/usr/lib/python2.7/site-packages/certbot/renewal.py", line 474, in handle_renewal_request
len(renew_failures), len(parse_failures)))
Error: 1 renew failure(s), 0 parse failure(s)

試したこと

ネットで調べてみると.well-known/acme-challenge/にアクセスできないことが原因 ということなんだろうとは思うのですが、
下記を試してみましたが、すべて同じエラーとなってしまいます。

・.well-known/acme-challenge/を作成してみて試した。
・httpdをstopして試した。
・ECCUBEのリダイレクト等が原因かと思い、index.phpとhtaccessを一度削除して試した。
・certbot renew --dry-run ではなく、もともと打ち込んだコマンドを使って試した。
certbot certonly --webroot -w /var/www/html -m アドレス -d ドメイン --agree-tos

ショッピングサイトですが、本格始動していないのもあり、サーバとめたり等も今ならできます。
ただ、2/7がlet's encryptの更新期限となっており、それまでになんとかしたいもので、焦っております。。

どなたかご助力いただけると助かります。
情報として足りないものがあれば開示します。

よろしくお願いします。

追記

その後、調べてみた追記となります。

httpへアクセスするとhttpsにリダイレクトしてしまう設定が問題を起こしているのかもしれないと思い、
httpd.conf内に書いてあった

<VirtualHost *:80>
ServerAdmin root@〇〇〇〇〇.com
DocumentRoot /var/www/html
ServerName 〇〇〇〇〇.com
RewriteEngine on
RewriteCond %{SERVER_NAME} =〇〇〇〇〇.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

のRewrite関連の部分を
#RewriteEngine on
#RewriteCond %{SERVER_NAME} =〇〇〇〇〇.com
#RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanen

にしてみて
certbot certonly --webroot -w /var/www/html -m アドレス -d ドメイン --agree-tos
を試してみたのですが
ダメでした・・

なお、httpでアクセスするとinternalservererrorになり、well-known/も同様にinternalservererrorとなりました。

let's encryptのwel-knownの部分のエラーも「404Not Found」から「500 Internal Server」に変わったのですが、
このあたりは関係してきますでしょうか。

何もわからずすみません。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

okubo

2020/01/22 02:37

修正依頼ありがとうございます!リンク設定を見落としていました!以後気を付けます。
guest

回答1

0

ベストアンサー

certbot は、一時的に Webサーバーの設定ファイルを書き換え、.well-known/acme-challenge 用のリライト設定を埋め込みます。

<VirtualHost> が重複して設定されているなどの理由で、certbot が別の設定ファイルを書き換えてしまって、404 となっている可能性があります。
certbot がどの設定ファイルを書き換えるのかは、以下のようなログで確認することができます。

DEBUG:certbot_apache._internal.http_01:Adding a temporary challenge validation Include for name: ドメイン名:80 in: 設定ファイル

投稿2020/01/21 05:24

TaichiYanagiya

総合スコア12141

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

okubo

2020/01/22 02:38

ご丁寧にご回答いただき、本当にありがとうございます。いただいた内容で少し調べてみます。またわからなかったらご連絡させていただきます。
okubo

2020/01/22 05:10

ご指摘いただいた「<VirtualHost> が重複して設定されているなどの理由で…」が怪しいと思い、 調べていたところ、メールサーバー用に設定していたVirtualHostの部分を修正したらcertbotが成功しました!ありがとうございます。 なお、メールサーバーの部分で以前に四苦八苦し https://centossrv.com/postfix-dovecot-certbot.shtml を参考にバーチャルホスト設定ファイルを作っていました。 /etc/httpd/conf.d/内に virtualhost-〇〇〇〇〇.com.conf というのを作成しており、下記がその内容となります。 <VirtualHost *:80> ServerName 〇〇〇〇〇.com ServerAlias mail.〇〇〇〇〇.com DocumentRoot /var/www/html/support </VirtualHost> この「/var/www/html/support」の部分を「/var/www/html」に変更し、apacheを再起動したところ certbotが成功しました。 追加質問ともなってしまうのですが この成功の際、 - Congratulations! Your certificate and chain have been saved at: /etc/letsencrypt/live/〇〇〇〇〇.com/fullchain.pem Your key file has been saved at: /etc/letsencrypt/live/〇〇〇〇〇.com/privkey.pem Your cert will expire on 2020-04-21. To obtain a new or tweaked version of this certificate in the future, simply run certbot again. To non-interactively renew *all* of your certificates, run "certbot renew" - If you like Certbot, please consider supporting our work by: このように表示されたのですが 期限が 2020-04-21 までになり、 更新は成功した と言って大丈夫なのでしょうか。
TaichiYanagiya

2020/01/22 08:46

成功していると思います。 ブラウザから https:// で接続して、「証明書の表示」などのメニューで期限を確認すると、より確実かと思います。
okubo

2020/01/23 04:21

ご返信ありがとうございます。「証明書の表示」に反映されていなかったのですが、httpdを再起動していなかったためでした。。httpd再起動後確認したら更新期限が伸びていました!安心です。自動更新ができたらいいのですが、何かの機会に挑戦してみます!
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問