HTTPSの対応

投稿者:

今更投稿しますが1月13日のこと。

この記事はちゃんと書ききれていないので、参考程度にしてください。Raspberry pi 2 model Bに再設定した際に、(おそらくconfファイルの書き方が適切でなく)うまくいかず試行錯誤したものの原因の追及が仕切れませんでした。

よそ様のサイトを参考にSSL証明書を導入して、きちんとHTTPSに対応できるよう試みた。

https://www.server-world.info/query?os=Debian_10&p=ssl&f=2

あらかた参照先のページに書いてある通りの作業だけど、読み方がわかりにくかった。ピンクがサイトとしての説明、緑が入力内容、白が表示内容だった

このサイトで、aptで入れたwordpressをそのまま使うのであれば、証明書の取得はコマンドラインでは下のようになる。

sudo certbot certonly --webroot -w /usr/share/wordpress -d snowflake.forecast.mydns.jp

実行結果で、 参照先サイトと違ってCongratulationと言ってくれなかった。さらに最後にエラーが出て怒られたけど、大丈夫だろうか…。

心配になったのでもう一回同じコマンドを投入すると、途中のメールアドレスの確認とかをすっ飛ばして、参照先と同じようなメッセージ(Congratulationを含む)を表示して終わった。 大丈夫かなぁ?1回目にできていなかったファイルもできたし、大丈夫と信じるしかないか…これでいいのか?

liveフォルダにできたファイルを”chmod 400 *.pem”ですべて所有者(root)のみの読み取り専用に変更。(アクセス権限のないフォルダが複数階層あってcdもlsもワイルドカード展開も制約されて大変なので、”sudo bash”して作業した)

また、これらファイルを apacheのhttpsアクセス用の
(/etc/apache2/site-enabled/以下にある) confファイルに下のような感じで設定。

SSLCertificateFile /etc/letsencrypt/live/snowflake.forecast.mydns.jp/cert.pem     SSLCertificateKeyFile /etc/letsencrypt/live/snowflake.forecast.mydns.jp/privkey.pem     SSLCertificateChainFile /etc/letsencrypt/live/snowflake.forecast.mydns.jp/chain.pem

これでちゃんと動くはず…?

なお、1回目に証明書を取得しようとしたときに怒られた内容は下のような感じ。

An unexpected error occurred:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 384, in _make_request
six.raise_from(e, None)
File "", line 3, in raise_from
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 380, in _make_request
httplib_response = conn.getresponse()
File "/usr/lib/python3.7/http/client.py", line 1321, in getresponse
response.begin()
File "/usr/lib/python3.7/http/client.py", line 296, in begin
version, status, reason = self._read_status()
File "/usr/lib/python3.7/http/client.py", line 257, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/usr/lib/python3.7/socket.py", line 589, in readinto
return self._sock.recv_into(b)
File "/usr/lib/python3/dist-packages/urllib3/contrib/pyopenssl.py", line 307, in recv_into
raise timeout('The read operation timed out')
socket.timeout: The read operation timed out


During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/requests/adapters.py", line 449, in send
timeout=timeout
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 367, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/usr/lib/python3/dist-packages/six.py", line 693, in reraise
raise value
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 386, in _make_request
self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 306, in _raise_timeout
raise ReadTimeoutError(self, url, "Read timed out. (read timeout=%s)" % timeout_value)
urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='acme-v02.api.letsencrypt.org', port=443): Read timed out. (read timeout=45)

During handling of the above exception, another exception occurred:

requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='acme-v02.api.letsencrypt.org', port=443): Read timed out. (read timeout=45)
Please see the logfiles in /var/log/letsencrypt for more details.

返信を残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です