Let’s Encrypt (certbot)

Linux

環境

$ cat /etc/system-release
Rocky Linux release 9.8 (Blue Onyx)

$ httpd -v
Server version: Apache/2.4.62 (Rocky Linux)
Server built:   May 11 2026 00:00:00

インストール

$ sudo dnf -y install certbot

証明書の発行

$ sudo certbot certonly --webroot --agree-tos -m <メールアドレス> -w <ドキュメントルート> -d tech.hyperforest.jp

<省略>

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

<省略>

Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/tech.hyperforest.jp/fullchain.pem
Key is saved at:         /etc/letsencrypt/live/tech.hyperforest.jp/privkey.pem

<省略>

メールアドレスを利用する旨のメッセージが出るので”Y”と答えておく。

無事証明書が発行される。

fullchain.pemにはこのサイトの証明書と中間証明書が含まれている。

privkey.pemには秘密鍵が含まれている。

apacheの設定

証明書が発行されたのでapacheの設定に反映する。

    SSLCertificateFile    /etc/letsencrypt/live/tech.hyperforest.jp/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/tech.hyperforest.jp/privkey.pem

サイトの確認方法

-dでドキュメントルートを指定するのは、certbotがサイトの認証をするために証明書発行サイトのリクエストに応じて一時的なファイルを置く必要があるらしい。証明書発行サイトがこの一時的なファイルへアクセスする事でcertbotがサイトの所有権を持っている事を確認している。

証明書の期限の確認

$ sudo certbot certificates
Saving debug log to /var/log/letsencrypt/letsencrypt.log

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Found the following certs:
  Certificate Name: tech.hyperforest.jp
    Serial Number: 5aef68c1f902a70dcdc0d187aa4e8123532
    Key Type: ECDSA
    Domains: tech.hyperforest.jp
    Expiry Date: 2026-10-12 01:29:59+00:00 (VALID: 89 days)
    Certificate Path: /etc/letsencrypt/live/tech.hyperforest.jp/fullchain.pem
    Private Key Path: /etc/letsencrypt/live/tech.hyperforest.jp/privkey.pem
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

証明書の更新

$ sudo certbot renew
Saving debug log to /var/log/letsencrypt/letsencrypt.log

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing /etc/letsencrypt/renewal/tech.hyperforest.jp.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Certificate not yet due for renewal

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
The following certificates are not due for renewal yet:
  /etc/letsencrypt/live/tech.hyperforest.jp/fullchain.pem expires on 2026-10-12 (skipped)
No renewals were attempted.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

まだ更新可能時期に来ていないのでスキップされてしまった。

Linux
スポンサーリンク
シェアする
forestをフォローする

コメント

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