AWSのUbuntuのSSL化

AWSのubuntuを無料のSSL化ました。

https://wspri.dip.jp

でアクセスできます。

Let’s EncryptのSSL証明書を使っています。

 

設定は簡単です。まず、rootでSSHにログインしてコンソールに

apt -y install certbot

と入力します。これでClientのcertbotがインストールされます。

次に証明書を発行しましょう。

certbot certonly --webroot -w /var/www/html -d wspri.dip.jp

で、DdocumentRootとアクセスしたいドメイン名を指定します。すると問い合わせ可能なメアドを聞いてきますので入力します。

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):

で、あとは利用許諾をするかしないかを選択して終わりです。が、おまけに財団に協力するかとか聞いてきます。

-------------------------------------------------------------------------------
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

-------------------------------------------------------------------------------
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
An unexpected error occurred:
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Please see the logfiles in /var/log/letsencrypt for more details.

IMPORTANT NOTES:
 - 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.

僕は一度失敗したのでもう一回やり直しました。

あとは/etc/letsencrypt/live/ドメイン/の中にcert.pem、chain.pem、fullchain.pem、privkey.pemがありますので通常の手順で設定してApache2の再起動で終わりです。

vi /etc/apache2/sites-available/default-ssl.conf

SSLCertificateFile      /etc/letsencrypt/live/wspri.dip.jp/cert.pem
SSLCertificateKeyFile   /etc/letsencrypt/live/wspri.dip.jp/privkey.pem

SSLCertificateChainFile /etc/letsencrypt/live/wspri.dip.jp/chain.pem

尚証明書の更新にはまず、期限を確認します

sudo certbot certificates

こうすると時間かかりますが以下が返ってきます。

Saving debug log to /var/log/letsencrypt/letsencrypt.log
 
-------------------------------------------------------------------------------
Found the following certs:
  Certificate Name: example.com
    Domains: example.com
    Expiry Date: 2020-03-03 08:15:28+00:00 (VALID: 81 days)
    Certificate Path: /etc/letsencrypt/live/example.com/fullchain.pem
    Private Key Path: /etc/letsencrypt/live/example.com/privkey.pem
-------------------------------------------------------------------------------

まあ、あと81日で有効期限が終わるようです。
なので30日を切ったら以下のコマンドを実行します。

certbot renew

事前にテストをする場合は

certbot renew --dry-run

としますが0.32以前のバージョンだとエラーが出るようです。

コメントを残す

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

CAPTCHA


日本語が含まれない投稿は無視されますのでご注意ください。(スパム対策)