無料のSSL証明書を入れてみた

LineのChat Botで遊ぶにあたりSSL証明書が必要になったので、
無料で利用できるものを入れてみた。

サーバはかなり前から放置していたdebian

$ cat /etc/debian_version 
7.8

利用するのは letsencrypt

まず行うのはgit clone

$ git clone https://github.com/letsencrypt/letsencrypt
Cloning into 'letsencrypt'...
remote: Counting objects: 36783, done.
remote: Compressing objects: 100% (104/104), done.
remote: Total 36783 (delta 56), reused 0 (delta 0), pack-reused 36678
Receiving objects: 100% (36783/36783), 9.98 MiB | 1.19 MiB/s, done.
Resolving deltas: 100% (26181/26181), done.

ちなみにletsencryptは古い方らしく、今はcertbotらしい。

次にsetupする

$ cd letsencrypt
$ ./letsencrypt-auto --help

ここでワラワラワラっとダウンロードが始まる
Perlの依存関係を解決しつつ色々やってくれるようだ。
最終的に下記のHelpが出ればOK

  letsencrypt-auto [SUBCOMMAND] [options] [-d domain] [-d domain] ...

Certbot can obtain and install HTTPS/TLS/SSL certificates.  By default,
it will attempt to use a webserver both for obtaining and installing the
cert. Major SUBCOMMANDS are:

  (default) run        Obtain & install a cert in your current webserver
  certonly             Obtain cert, but do not install it (aka "auth")
  install              Install a previously obtained cert in a server
  renew                Renew previously obtained certs that are near expiry
  revoke               Revoke a previously obtained certificate
  register             Perform tasks related to registering with the CA
  rollback             Rollback server configuration changes made during install
  config_changes       Show changes made to server config during installation
  plugins              Display information about installed plugins

Choice of server plugins for obtaining and installing cert:

  --apache          Use the Apache plugin for authentication & installation
  --standalone      Run a standalone webserver for authentication
  (nginx support is experimental, buggy, and not installed by default)
  --webroot         Place files in a server's webroot folder for authentication

OR use different plugins to obtain (authenticate) the cert and then install it:

  --authenticator standalone --installer apache

More detailed help:

  -h, --help [topic]    print this message, or detailed help on a topic;
                        the available topics are:

   all, automation, paths, security, testing, or any of the subcommands or
   plugins (certonly, install, register, nginx, apache, standalone, webroot,
   etc.)

ここまで来たら後は証明書を発行するだけ。
ちなみに、作成と設定を一緒にやってくれる。素敵。

$ ./letsencrypt-auto --apache
Requesting root privileges to run certbot...

パスワードを入れると、色々聞かれる
1. 実行すると、VirtualHostsを切っていたのでどのHostか選択し

2. Email情報を入力し、
3. Agreeする
これでOK簡単だね。

うまくいくとこのように表示される

ここにものっているけど、テストはこういうところでできるらしい
https://www.ssllabs.com/ssltest/analyze.html?d=<ホスト名>

これでLine Botで遊べそうだ。