https SSL/TLS証明書の取得

SSL/TLS証明書について

SSL/TLSとはインターネット上のデータの送受信を暗号化して行う技術を言います。
SSL/TLS証明書とはSSL/TLSの技術を使って認証局(CA)が発行する電子証明書のことを言います。

証明書の種類
ドメイン(DV)認証、最も安価でドメインを所有していると確認された場合に発行されます。
企業実在(OV)認証、ドメインの所有と企業の実在が確認された場合に発行。
EV認証、最も高価で信頼性が高い証明書です。ドメインの所有、組織の実在、運営、証明者の確認等厳しい審査が行われます。

今回はLet’s Encryptから無料のDV型証明書を取得します。
公式サイト FAQより

Let’s Encrypt はどのようなサービスを提供しているのですか?

Let’s Encrypt は世界的な認証局 (Certificate Authority; CA) です。 私たちの目的は、世界中の人々と組織が SSL/TLS 証明書を取得・更新・管理できるようにすることです。 私たちの証明書は、ウェブサイトなどで HTTPS コネクションをセキュアにするために利用できます。
Let’s Encrypt はドメイン検証 (Domain Validation; DV) 型の証明書です。 主に Organization Validation (OV) や Extended Validation (EV) は提供しません。このような種類の証明書の発行は自動化することができないからです。

certbotのインストール

certbotとはLet’s Encryptから提供されている無料、自動化でSSL証明書を発行、更新できるツールです。

# pkg search certbot
py311-certbot-2.11.0,1 Let’s Encrypt client
py311-certbot-apache-2.11.0 Apache plugin for Certbot
# pkg install -y py311-certbot

The process will require 39 MiB more space.
6 MiB to be downloaded.
Proceed with this action? [y/N]:y
#yを入力

In order to automatically renew the certificates, add this line to
/etc/periodic.conf:

weekly_certbot_enable=”YES”

More config details in the certbot periodic script:

/usr/local/etc/periodic/weekly/500.certbot-3.11

Let’s Encrypt SSL/TLS証明書の取得

− −webrootでapacheを停止することなく証明書の取得、更新が出来ます。
-wでドキュメントルート指定
-dで証明書を取得するFQDNを指定します。

− −standaloneではapacheを停止しないと取得、更新が出来ません。
-wの指定は不要、-dでFQDNを指定します。

いずれの場合もインターネット側から80番に、アクセスできることが条件となります。

# certbot certonly − −webroot -w /usr/local/www/apache24/data -d jsnsver.com

Enter email address
(Enter ‘C’ to cancel):hoge@jsnsver.com
#メールアドレス登録

Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.4-April-3-2024.pdf. You musut agree in
order to register with the ACME server. Do you agree?
(Y)es/(N)o:y
#同意しますか y

Would you be willing, once your first certificate is successfully issued, 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 our work encrypting the web,
EFF news, campaigns, and ways to support digital freedom.
(Y)es/(N)o:y
#Let’s Encrypt プロジェクトの創設パートナーであり、Certbot を開発している非営利団体である
#Electronic Frontier Foundation にメールアドレスを登録しますか y

Successfully received certificate.
Certificate is saved at: /usr/local/etc/letsencrypt/live/isnsver.com/fullchain.pem
#fullchsin.pem SSL証明書、公開鍵と中間証明書
Key is saved at: /usr/local/etc/letsencrypt/live/jsnsver.com/privkey.pem
#privkey.pem 公開鍵用の秘密鍵
This certificate expires on 2024-12-31.
These files will be updated when the certificate renews.

# − −standaloneではこんな感じでいいと思います。
#service apache24 stop
#certbot certonly − −standalone -d jsnsver.com
#更新もapacheを停止させる必要があります。

証明書の有効期限更新

証明書の有効期限は90日となっておりかなり短いです。更新できるのは有効期限が30日未満の場合に限ります。

# certbot renew
#手動更新の場合

#パッケージ付属の自動更新スクリプトを使う場合
#cd /usr/local/etc/periodic/weekly
#ls
400.status-pkg 500.certbot-3.11
#ls -l 500.certbot-3.11
-r-xr-xr-x 1 root wheel 2435 Sep 5 22:22 500.certbot-3.11
#更新スクリプト確認

# ee /etc/defaults/periodic.conf
weekly_certbot_enable=”YES”
# ↑ 追記

毎週土曜日、明け方ころに更新されるようです。

証明書の有効期限更新シュミレーション

手動更新に − −dry-run をつける事により更新のシュミレーションが出来ます。最後にsuccessと出ればOKです。

# certbot renew − −dry-run

Congratulations, all simulated renewals succeeded:
/usr/local/letsencrypt/live/jsnsver.com/fullchain.pem(success)

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