まぬねこの足跡。。。

備忘録+たのしさ+ひっそりと

SSL証明書 Let’s Encrypt

環境

ちょこっとメモ

SSL

インターネット上の通信を暗号化するため仕組み
ちょこっとメモ

SSL証明書

ドメイン認証(DV)ドメイン名 確認
実在証明型(OV)ドメイン名、会社名の確認
実在証明拡張型(EV)ドメイン名の確認 実在証明
DV、OV以上のきびしい審査有。
アドレスバーに、組織情報が表示。

ちょこっとメモ

Let’s Encrypt

手順

1.ApacheSSLモジュールmod_ssl導入

導入されているか確認

[root@localhost ~]# httpd -M
   :
ssl_module (shared)  ←あれば導入済み
   :

※導入されてなければ下記でmod_ssl導入

[root@localhost ~]# yum install mod_ssl
    :
Is this ok [y/d/N]: y
    :

再起動してSSLを有効する

[root@localhost ~]# systemctl restart httpd

2.https用の443番ポート ファイアウォール許可確認

[root@localhost ~]# firewall-cmd --list-all
   :
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: eth0
  sources:
  services: dhcpv6-client ssh http https ←「https」があればOK!
  ports:
  protocols:

   :

ファイアウォール許可されてなければ、

[root@□□-□□□□ ~]# firewall-cmd --add-service=https --zone=public --permanent
success ※成功
[root@□□-□□□□ ~]# systemctl restart firewalld ←ファイアウォール再起動

※非表示でOK!!

3.Let’s Encryptのインストール

[root@□□-□□□□ ~]# yum install certbot python2-certbot-apache
    :
Is this ok [y/d/N]: y
    :

4.証明書をインストール

※XXXXX.XXXX は自分のドメイン

[root@□□-□□□□ ~]# certbot --apache -d XXXXX.XXXX
    :
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel):   ←Let's Encryptからのお知らせ受取用メールアドレスを入力
    :
(A)gree/(C)ancel:A   ←「A」を入力:規約に同意。
    :
(Y)es/(N)o: Y    ←「Y」or「N」を入力:Let's EncryptパートナーにEmailを公開するか
    :
Press 1 [enter] to confirm the selection (press 'c' to cancel):1  ←「1」を入力:ssl.confを選択
    :
Select the appropriate number [1-2] then [enter] (press 'c' to cancel):2 ←「2」:httpアクセスをhttpsにリダイレクト。
    :

5.httpd再起動

下記を入力

[root@□□-□□□□ ~]# systemctl restart httpd

無表示でOK!

※これでSSL証明書が導入。。。
ブラウザのアドレスバーに鍵のマークが表示される。
独自ドメインURLの詳細の「発行者 一般名称(CN) に Let’s Encrypt~~」
            「      組織(O) に Let’s Encrypt」が表示。

6.Let’s Encrypt SSL証明書の更新 …3カ月毎の更新必須

※証明書の有効期限の残り30日未満の場合のみ更新。

下記を入力

[root@□□-□□□□ ~]# certbot renew

※すぐに証明書を更新したい場合。

下記を入力

[root@□□-□□□□ ~]# certbot renew --force-renew

※スケジュールによる更新の場合。

crontabファイルをVimで起動
[root@localhost  ~]# # vim /etc/crontab
crontabファイル編集
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root

# For details see man 4 crontabs

# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name  command to be executed

0 0 1 * * root /usr/bin/certbot renew ←を記入 毎月1日に「certbot renew」コマンドを実行。

【入力する行の意味】
 0 0 1  *  *  root    /usr/bin/certbot renew

分 時 日  曜日 実行ユーザ  実行プログラム

※毎月1日に「/usr/bin/certbot renew」コマンドを実行する。
もし、証明書の有効期限の残り30日以上の場合は実行しても更新されない。