Let’s Encryptはじめました

技術


Let’s Encryptは、無料でSSL証明書を取得できるサービスのことです。
昨日作ったGitBucketサーバでSSL

ファイアウォールの設定

$ sudo firewall-cmd --list-all
$ sudo firewall-cmd --add-service=https --zone=public --permanent
$ sudo firewall-cmd --reload

Certbotクライアントのインストール

Let’s Encryptが発行するSSL/TLS サーバ証明書は、Certbotクライアントで簡単なコマンド操作で取得することができる。

$ sudo yum install epel-release
$ sudo yum install certbot python-certbot-apache

SSL証明書の取得

  1. コマンドを入力。今回はサブドメインで取得しました。
$ sudo certbot certonly --webroot -w /var/www/html -d git.hoge.com
  1. メールアドレスを入力
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator webroot, Installer None
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): 
[email protected]
  1. 利用規約への同意
Starting new HTTPS connection (1): acme-v01.api.letsencrypt.org

-------------------------------------------------------------------------------
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).
You must agree in order to register with the ACME server at
https://acme-v01.api.letsencrypt.org/directory
------------------------------------------------------------------------------- (A)gree/(C)ancel:
 a
  1. メーリングリストへの登録
-------------------------------------------------------------------------------
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
  1. 処理が進みます。
Starting new HTTPS connection (1): supporters.eff.org
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for git.hoge.com
Using the webroot path /var/www/html for all unmatched domains.
Waiting for verification...
Cleaning up challenges

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/git.hoge.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/git.hoge.com/privkey.pem
   Your cert will expire on 2018-01-27. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot
   again. To non-interactively renew *all* of your certificates, run
   "certbot 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

virtual.confの作成

  1. 設定ファイル作成
$ sudo vi /wetc/httpd/conf.d/virtual.conf
  1. 追記
NameVirtualHost *:80
NameVirtualHost *:443

<VirtualHost *:80>
    ServerName git.hoge.com
    <IfModule mod_rewrite.c>
        RewriteEngine on
        RewriteCond %{HTTPS} off
        RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
    </IfModule>
</VirtualHost>

<VirtualHost *:443>
    SSLEngine on
    SSLCertificateFile /etc/letsencrypt/live/git.hoge.com/cert.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/git.hoge.com/privkey.pem
    SSLCertificateChainFile /etc/letsencrypt/live/git.hoge.com/chain.pem

    ServerAdmin [email protected]
    DocumentRoot /var/www/html
    ServerName git.hoge.com
</VirtualHost>

コメント

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