無料SSL証明書Let's Encrypt導入

投稿者: | 2018年7月28日

Lets’s Encryptを導入するにはクライアントであるcertbotが必要らしいのでとりあえず導入します。
certbotはgithubで公開されていますがwgetでバイナリをダウンロードできます。

$ cd /usr/local
$ wget https://dl.eff.org/certbot-auto

certbotを利用してSSL証明書を発行します。

$ chmod a+x certbot-auto
$ ./certbot-auto

コマンドを実行すると対話モードで必要な情報を入力できます。
まずはメールアドレスを聞かれます。

Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): nekonoprotocol@excite.co.jp

続いて利用規約への同意をします。

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A

メールアドレスにお知らせを受け取るかどうか入力します。

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y

発行するSSL証明書のドメインを選択します。
2つ逆引きできたのか古い方と選択になりました。

Which names would you like to activate HTTPS for?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: protocol.nekono.tokyo
2: www.nekono.tokyo
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel): 1

リダイレクトするかどうか聞いてきました。
ミドルウェアを調べて勝手にconfを作ってくれるようです。

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): 2

必要な情報の入力が終わるとSSL証明書が発行されます。
httpd.confのインクルードを勝手に書き換えてhttpd-le-ssl.confを読み込むようになっています。
必要な証明書のパスや設定はhttpd-le-ssl.confに記述されていました。
続いてSSL証明書の自動更新を行います。
コマンド一発でできるらしいのでクーロンで設定します。

vi /etc/crontab

2ヶ月に1回、朝6時とかに設定しておきます。
60日毎くらいに更新することを推奨されているみたいなのでそれに合わせます。

00 6 1 */2 * root /usr/bin/certbot-auto renew --post-hook "service httpd restart"

以上で設定作業完了となります。
certbot実行にエラーが発生しましたが対応方法は1つ前の記事で記述しておきました。
こちら

コメントを残す

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

CAPTCHA