certbotを導入し、Let’s Encryptで無料SSLを利用する

Linux

Googleがリリースする「chrome68」から、すべてのHTTPサイトで「保護されていません」という警告が表示されるようになりました。

これまでは、会員サイトなど一部のセキュアな通信が求められる場所で多く利用されていたSSLですが、SSL化しているサイトは検索結果の順位が上がり、SSL化されていないサイトは検索順位が下がるようになってきています。

お金を払って取得すれば、解決できますが当サイトのように個人で運用している場合、さらに費用がかかってくるようになってしまい、悩みの種になりかねません。

そんな悩みのたねを解消してくれるのが、「Let’s Encrypt」です。

なんと、無料で証明書が取得できてしまいます。
さらにすごいのが、結構お高いワイルドカード証明書まで、無料で取得できちゃうんです。

Let’s Encrpytについての説明はこのくらいで、、、今回は「certbot」と言うツールを利用し、Let’s Encryptから無料で証明書を取得していきます。

導入方法

まずは、gitからcertbotを取得します。

git clone https://github.com/certbot/certbot

次に、取得したcertbotに対し、シンボリックリンクを作成します。

ln --symbolic $PWD/certbot/certbot-auto /usr/local/sbin/

最後にcertbotで利用する、依存パッケージをインストールします。

certbot-auto --install-only

インストール後に、certbotのバージョンを確認します。

certbot-auto --version

証明書の取得方法

以下のコマンドを実行することで、インタラクティブ(対話形式)の入力が始まります。

certbot-auto certonly

まずは、Let’s Encryptを利用する際のアカウント(メールアドレス)を設定します。

Saving debug log to /var/log/letsencrypt/letsencrypt.log

Plugins selected: Authenticator nginx, Installer nginx
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel):

次に、確認が2つ出てきますが、悩むことなく「A」と「Y」を押下してください。

Please read the Terms of Service at
404 Page not found - Let's Encrypt
Let's Encrypt is a free, automated, and open certificate authority brought to you by the nonprofit Internet Security Research Group (ISRG). Read all about our n...
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: N

次に、ドメインの認証方法を選択する様に促されますので、悩むことなく「3」を選んでください。

How would you like to authenticate with the ACME CA?

1: Nginx Web Server plugin (nginx)
2: Spin up a temporary webserver (standalone)
3: Place files in webroot directory (webroot)

Select the appropriate number [1-3] then [enter] (press 'c' to cancel):

証明書を取得したいドメインを、半角スペースまたは半角カンマで区切って入力してください。

Plugins selected: Authenticator webroot, Installer None
Please enter in your domain name(s) (comma and/or space separated) (Enter 'c'
to cancel):

最後に、WEBサーバのドキュメントルートを指定してください。

Obtaining a new certificate
Performing the following challenges:
http-01 challenge for test-site.com
Input the webroot for test-site.com: (Enter 'c' to cancel):

取得完了まで少し待ちます。

Waiting for verification…
Cleaning up challenges

正常に取得が完了すると、以下のような内容が表示されます。

IMPORTANT NOTES:
Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/test-site.com/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/test-site.com/privkey.pem
Your cert will expire on 2019-11-02. To obtain a new or tweaked
version of this certificate in the future, simply run certbot-auto
again. To non-interactively renew all of your certificates, run
"certbot-auto renew"
If you like Certbot, please consider supporting our work by:
Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
Donating to EFF: https://eff.org/donate-le

総括

幾つかのコマンドを実行するだけで、数千円~数万円する証明書が無料で取得できました。

ただ、Let’s Encryptの証明書は3か月で期限が切れてしまうため、期限前に更新を行う必要が出てきます。

更新処理や、ApacheおよびNginxへの証明書の設定方法については、また別の個所で記載していきます。

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