無料SSLサーバー証明書 Let's Encrypt インストール

この章を始める前に下記の設定が必要です
「Apache2 インストール」 or 「Nginx インストール」 「Apache2 バーチャルホスト 設定」 or 「Nginx バーチャルホスト 設定」
Certbotインストール
[root@centos ~]# wget https://dl.eff.org/certbot-auto
[root@centos ~]# chmod +x certbot-auto
[root@centos ~]# ./certbot-auto
・
・
・
総ダウンロード容量: 7.0 M
インストール容量: 20 M
Is this ok [y/d/N]: y ←yを入力してエンター(関連パッケージのインストール)
・
・
・
完了しました!
Upgrading certbot-auto 0.21.1 to 0.22.0...
Replacing certbot-auto...
Creating virtual environment...
Installing Python packages...
Installation succeeded.
Saving debug log to /var/log/letsencrypt/letsencrypt.log

How would you like to authenticate and install certificates?
-------------------------------------------------------------------------------
1: Apache Web Server plugin - Beta (apache)
2: Nginx Web Server plugin - Alpha (nginx)
-------------------------------------------------------------------------------
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 1 ←Apacheの場合1、Nginxの場合2を入力してエンター(Webサーバーを選択)
Plugins selected: Authenticator nginx, Installer nginx
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): postmaster@server-manual.com ←メールアドレスを入力してエンター

-------------------------------------------------------------------------------
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-v01.api.letsencrypt.org/directory
-------------------------------------------------------------------------------
(A)gree/(C)ancel: A ←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: N ←Nを入力してエンター(EFFにメールアドレスを登録しない)

Which names would you like to activate HTTPS for?
-------------------------------------------------------------------------------
1: server-manual.com
2: virtual.server-manual.com
-------------------------------------------------------------------------------
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel): 1 ←1を入力してエンター(HTTPS化するアドレスを選択)
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for server-manual.com
Waiting for verification...
Cleaning up challenges
Deployed Certificate to VirtualHost /etc/nginx/conf.d/virtualhost.conf for server-manual.com

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): 1 ←1を入力してエンター(HTTPSへリダイレクトさせない)

-------------------------------------------------------------------------------
Congratulations! You have successfully enabled https://server-manual.com

You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=server-manual.com
-------------------------------------------------------------------------------

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/server-manual.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/server-manual.com/privkey.pem
   Your cert will expire on 2018-06-03. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot-auto
   again with the "certonly" option. 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
ヒント
ドメインを複数設定する場合も同様に「./certbot-auto」を実行してください。
Let's Encryptの有効期限は3ヶ月なので期限が切れる前に更新する必要があります。
SSLサーバー証明書の設定
[root@centos ~]# vi /etc/httpd/conf.d/ssl.conf
#SSLCertificateFile /etc/pki/tls/certs/localhost.crt
↓
SSLCertificateFile /etc/letsencrypt/live/server-manual.com/cert.pem ←コメント解除&変更(公開鍵)

#SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
↓
SSLCertificateKeyFile /etc/letsencrypt/live/server-manual.com/privkey.pem ←コメント解除&変更(秘密鍵)

#SSLCertificateChainFile /etc/pki/tls/certs/server-chain.crt
↓
SSLCertificateChainFile /etc/letsencrypt/live/server-manual.com/chain.pem ←コメント解除&変更(中間証明書)
[root@centos ~]# systemctl restart httpd
Let's Encrypt自動更新(Apacheの場合)
[root@centos ~]# vi /etc/cron.monthly/certbot
#!/bin/sh

/root/certbot-auto renew --post-hook "systemctl restart httpd"
[root@centos ~]# chmod +x /etc/cron.monthly/certbot
Let's Encrypt自動更新(nginxの場合)
[root@centos ~]# vi /etc/cron.monthly/certbot
#!/bin/sh

/root/certbot-auto renew --post-hook "systemctl restart nginx"
[root@centos ~]# chmod +x /etc/cron.monthly/certbot
証明書の保存場所
/etc/letsencrypt/live/server-manual.com/cert.pem ←サーバ証明書(公開鍵)
/etc/letsencrypt/live/server-manual.com/chain.pem ←中間証明書
/etc/letsencrypt/live/server-manual.com/fullchain.pem ←サーバ証明書と中間証明書が結合されたファイル
/etc/letsencrypt/live/server-manual.com/privkey.pem ←秘密鍵
ブラウザで確認 (https://ドメイン名/ にアクセス)

外部に公開する場合
プロトコル(TCP)ポート443番(HTTPS)を開放。
Home PageTop