Certbot で無料の SSL を自動発行

Certbot を使用して Let’s Encrypt から無料の SSL 証明書を発行してもらいます。

サーバー
LXD ゲスト
CPU
2コア
メモリー
4GB
OS
Ubuntu Server 24.04 LTS 64Bit
snap パッケージ バージョン
certbot

3.2.0

前提条件

SSL 証明書を発行する条件として外部からポート 80 でサーバーにアクセス可能である必要があります。

パッケージをインストール

以下のコマンドで certbot をイストールします。

sudo snap install --classic certbot

以下のコマンドでバイナリへのシンボリックリンクを作成します。

sudo ln -s /snap/bin/certbot /usr/bin/certbot

ファイアウォールを設定

以下のコマンドで 80 ポートへのアクセスを許可しておきます。

sudo ufw allow 80/tcp

Certbot を設定

以下のコマンドで設定します。

sudo certbot certonly --standalone
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Enter email address (used for urgent renewal and security notices)
 (Enter 'c' to cancel): foo@example.com

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at:
https://letsencrypt.org/documents/LE-SA-v1.4-April-3-2024.pdf
You must agree in order to register with the ACME server. Do you agree?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: 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: N
Account registered.
Please enter the domain name(s) you would like on your certificate (comma and/or
space separated) (Enter 'c' to cancel): foo.example.com
Requesting a certificate for foo.example.com

Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/foo.example.com/fullchain.pem
Key is saved at:         /etc/letsencrypt/live/foo.example.com/privkey.pem
This certificate expires on 2025-05-03.
These files will be updated when the certificate renews.
Certbot has set up a scheduled task to automatically renew this certificate in the background.

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

/etc/letsencrypt/live/foo.example.com/fullchain.pem に証明書が保存されているのでメールサーバー等で使用します。

以降は証明書の期限が切れる前に自動的に更新されます。

参考

コメントを残す

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