無料のSSL証明書 Let’s EncryptをCentOS6に導入してみました

httpsにするのにSSL証明書が必要です。

このSSL証明書ですが、普通は業者さんから1年単位で購入します。

費用としては、目的やその他様々な要因により異なりますが1,000円〜240,000円(税別)くらいになります。

また、自分でSSL証明書を発行しちゃうても有ります。これをオレオレ証明書とか自己証明書とかといいます。

ところが、最近、SSL証明書を無料で入手できる、というか無料で使わせてもらえるサービスが始まっています。

これは「Let’s Encrypt」というサービスです。

サイトはこちら

自分のサーバーの環境設定は必要ですが、手順が詳細にポータルサイトに記載されているので導入は比較的早くできます。

今回は、CentOS6.5+nginxな環境に導入してみました。

※導入後の自動更新はこちらを参照下さい。

必要なモジュールを入手します。

$ 作業用のディレクトリを作成ます。

$ cd 作業用ディレクトリ

$ git clone https://github.com/letsencrypt/letsencrypt

$ cd letsencrypt

インストールします。

この際、足りないモジュールやアップデートが必要なモジュールは更新されるので、rootで作業をします。

# ./letsencrypt-auto –help

ここで、足りないモジュールやアップデートが必要なモジュールはyumで更新されます。

pythonやなんやと更新されますので、必ず実行して下さい。

証明書を作成します。

今回はスタンドアロンで作成します。

途中で、環境確認のためにhttpdが起動されます。その時、httpポートが塞がっているとエラーとなるため、httpdデーモンを停止させます。

また、インタラクティブで作成をします。

# ./certbot-auto certonly –standalone -t

ホスト名やメールアドレスなんかを聞かれながら証明書の作成が行われます。

Creating virtual environment…
Installing Python packages…
Installation succeeded.
/root/.local/share/letsencrypt/lib/python2.6/site-packages/cryptography/__init__.py:26: DeprecationWarning: Python 2.6 is no longer supported by the Python core team, please upgrade your Python. A future version of cryptography will drop support for Python 2.6
DeprecationWarning
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Enter email address (used for urgent renewal and security notices) (Enter ‘c’ to
cancel): info@kumakake.com

——————————————————————————-
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.1.1-August-1-2016.pdf. You must agree
in order to register with the ACME server at
https://acme-v01.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 EFF and
our work to encrypt the web, protect its users and defend digital rights.
——————————————————————————-
(Y)es/(N)o: Y
Please enter in your domain name(s) (comma and/or space separated) (Enter ‘c’
to cancel): ngxtst.kumakake.com
IMPORTANT NOTES:
– Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/ngxtst.kumakake.com/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/ngxtst.kumakake.com/privkey.pem
Your cert will expire on 2017-11-04. 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”
– Your account credentials have been saved in your Certbot
configuration directory at /etc/letsencrypt. You should make a
secure backup of this folder now. This configuration directory will
also contain certificates and private keys obtained by Certbot so
making regular backups of this folder is ideal.
– 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

完了すると下記のようにファイルが作成されます。

# ls -al /etc/letsencrypt/
total 32
drwxr-xr-x 8 root root 4096 Aug 6 20:24 .
drwxr-xr-x. 86 root root 4096 Aug 6 20:21 ..
drwx—— 3 root root 4096 Aug 6 20:21 accounts
drwx—— 3 root root 4096 Aug 6 20:24 archive
drwxr-xr-x 2 root root 4096 Aug 6 20:24 csr
drwx—— 2 root root 4096 Aug 6 20:24 keys
drwx—— 3 root root 4096 Aug 6 20:24 live
drwxr-xr-x 2 root root 4096 Aug 6 20:24 renewal

コレで完了です。

この証明書は90日単位で更新する必要があります。

コメントを残す

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