「Certbot」の版間の差分
Kusanaginoturugi (トーク | 投稿記録) (→systemd: 自動起動のスクリプトの記述を修正) |
(同期) |
||
| 3行目: | 3行目: | ||
[[en:Let’s Encrypt]] |
[[en:Let’s Encrypt]] |
||
[[ru:Let’s Encrypt]] |
[[ru:Let’s Encrypt]] |
||
| − | [https://letsencrypt.org/ Let’s Encrypt] はフリーかつ自動化されたオープンな認証局です。[[Wikipedia:ja:Automated Certificate Management Environment|ACME]] プロトコルを利用しています。 |
+ | [https://letsencrypt.org/ Let’s Encrypt] はフリーかつ自動化されたオープンな[[Wikipedia:ja:認証局|認証局]]です。[[Wikipedia:ja:Automated Certificate Management Environment|ACME]] プロトコルを利用しています。 |
公式クライアントは '''Certbot''' という名前で、コマンドラインから有効な X.509 証明書を取得できます。また、手動で CSR 作成を行うミニマルなクライアントを {{AUR|acme-tiny}} でインストールすることができます。スクリプトで使用するのに適したクライアントとして {{AUR|simp_le-git}} や {{AUR|letsencrypt-cli}} も存在します。 |
公式クライアントは '''Certbot''' という名前で、コマンドラインから有効な X.509 証明書を取得できます。また、手動で CSR 作成を行うミニマルなクライアントを {{AUR|acme-tiny}} でインストールすることができます。スクリプトで使用するのに適したクライアントとして {{AUR|simp_le-git}} や {{AUR|letsencrypt-cli}} も存在します。 |
||
| 19行目: | 19行目: | ||
証明を作成・インストールする方法は [https://certbot.eff.org/docs/ Certbot のドキュメント] を参照してください。 |
証明を作成・インストールする方法は [https://certbot.eff.org/docs/ Certbot のドキュメント] を参照してください。 |
||
| − | === |
+ | === プラグイン === |
| + | {{Warning|プラグインを使用すると設定ファイルが上書きされます。先に設定ファイルのバックアップを作成することを推奨します。}} |
||
| + | ==== Nginx ==== |
||
| − | {{Note| |
||
| − | * Webroot 方式では Certbot で認証するのにポート 80 で HTTP 接続する必要があります。 |
||
| − | ** ポート 443 で HTTPS 接続を使って Certbot で認証するには、Webroot (''--webroot'') 方式の代わりに Nginx (''--nginx'') または Apache (''--apache'') プラグインを使用する必要があります。 |
||
| − | * サーバー名は DNS 名と一致していなければなりません。 |
||
| − | * ホスト上のパーミッションを修正して {{ic|<nowiki>http://domain.tld/.well-known</nowiki>}} への読み取り許可を与える必要があります。 |
||
| − | }} |
||
| + | {{pkg|certbot-nginx}} プラグインは [[nginx]] の [[nginx#サーバーブロック|server ブロック]]を自動的に設定します: |
||
| − | Webroot 方式では、Certbot クライアントによって {{ic|/path/to/domain.tld/html/.well-known/acme-challenge/}} でチャレンジ/レスポンス認証が行われます。 |
||
| + | # certbot --nginx |
||
| − | この使用方法は手動インストールよりも推奨されます。自動的に更新が行なわれ、証明書管理が容易になります。 |
||
| + | 証明書を更新するには: |
||
| − | {{Tip|1=始めて証明書を取得するときは以下の [[Nginx#サーバーブロック|nginx サーバー]]設定が役に立つでしょう: |
||
| − | {{hc|/etc/nginx/servers-available/domain.tld|<nowiki> |
||
| − | server { |
||
| − | listen 80; |
||
| − | listen [::]:80; |
||
| − | server_name domain.tld; |
||
| − | root /usr/share/nginx/html; |
||
| − | location / { |
||
| − | index index.htm index.html; |
||
| − | } |
||
| − | # ACME challenge |
||
| − | location ^~ /.well-known/acme-challenge/ { |
||
| − | default_type "text/plain"; |
||
| − | root /var/lib/letsencrypt; |
||
| − | } |
||
| − | }</nowiki>}} |
||
| − | }} |
||
| − | |||
| − | ==== 証明書の取得 ==== |
||
| − | |||
| − | 公開パスとして {{ic|/var/lib/letsencrypt/}} を使って {{ic|domain.tld}} の証明書を取得するには: |
||
| − | # certbot certonly --email ''email@example.com'' --webroot -w ''/var/lib/letsencrypt/'' -d ''domain.tld'' |
||
| − | |||
| − | (サブ)ドメインを追加する場合、登録済みの全てのドメインを一緒に指定します: |
||
| − | # certbot certonly --email ''email@example.com'' --webroot -w ''/var/lib/letsencrypt/'' -d ''domain.tld,sub.domain.tld'' |
||
| − | |||
| − | 登録している証明書を(全て)更新するには: |
||
# certbot renew |
# certbot renew |
||
| + | nginx の設定ファイルに手を加えずに証明書を変更するには: |
||
| − | 証明書の更新方法については[[#自動更新]]も参照。 |
||
| + | # certbot --nginx certonly |
||
| − | === 手動 === |
||
| + | 詳しい情報は [https://certbot.eff.org/#arch-nginx Nginx on Arch Linux] を見てください。インストールされた証明書の状態を有効に保つ方法は[[#自動更新]]を見てください。 |
||
| − | {{Note| |
||
| − | * この方法では、一時的にウェブサーバーを停止する必要があります。[[#Webroot]] の方法ではウェブサーバーを実行しながらでも認証が行えます。 |
||
| − | * この方法では、自動的に証明書を更新することはできません。自動更新を行いたい場合には、[[#Webroot]] メソッドを使用してください。}} |
||
| + | ===== サーバーブロックの管理 ===== |
||
| − | ウェブサーバーのプラグインが存在しない場合、次のコマンドを使って下さい: |
||
| + | サーバーブロックを手動で管理する場合、以下のように[[nginx#サーバーブロック|サーバーブロック]]で使うことができます: |
||
| − | # certbot certonly --manual |
||
| + | {{hc|/etc/nginx/sites-available/example|2= |
||
| + | server { |
||
| + | listen 443 ssl http2; |
||
| + | listen [::]:443 ssl http2; # Listen on IPv6 |
||
| + | ssl_certificate /etc/letsencrypt/live/''domain''/fullchain.pem; # managed by Certbot |
||
| + | ssl_certificate_key /etc/letsencrypt/live/''domain''/privkey.pem; # managed by Certbot |
||
| + | include /etc/letsencrypt/options-ssl-nginx.conf; |
||
| + | ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; |
||
| + | .. |
||
| + | } }} |
||
| + | 詳しくは [[nginx#TLS/SSL]] を見てください。 |
||
| − | DNS の TXT レコードを利用した認証を行う場合、次のコマンドを使って下さい: |
||
| − | # certbot certonly --manual --preferred-challenges dns |
||
| + | 別の設定ファイルを作成してサーバーブロックから include して使用することも可能です: |
||
| − | 上記のコマンドで自動的にドメインが認証されて秘密鍵と証明書のペアが作成されます。秘密鍵と証明書は {{ic|/etc/letsencrypt/live/''your.domain''/}} に保存されます。 |
||
| + | {{hc|/etc/nginx/conf/001-cerbot.conf|2= |
||
| − | 上記のディレクトリに入っている秘密鍵と証明書を使用するように手動でウェブサーバーを設定します。 |
||
| + | ssl_certificate /etc/letsencrypt/live/''domain''/fullchain.pem; # managed by Certbot |
||
| − | |||
| + | ssl_certificate_key /etc/letsencrypt/live/''domain''/privkey.pem; # managed by Certbot |
||
| − | {{Note|コマンドを複数回実行すると {{ic|/etc/letsencrypt/live/''your.domain''/}} に作られるファイルの名前には末尾に数字が付加されます。作成されたファイル名かウェブサーバーの設定を書き換える必要があります。}} |
||
| + | include /etc/letsencrypt/options-ssl-nginx.conf; |
||
| − | |||
| + | ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; |
||
| − | == 高度な設定 == |
||
| − | |||
| − | === ウェブサーバーの設定 === |
||
| − | |||
| − | プラグインを使用して自動で設定するのではなく、サーバーの SSL を手動で有効にすることが推奨される場合があります。 |
||
| − | |||
| − | {{Tip| |
||
| − | * Mozilla には有用な [https://wiki.mozilla.org/Security/Server_Side_TLS SSL/TLS についての記事] があり、セキュアな設定を作成するための [https://mozilla.github.io/server-side-tls/ssl-config-generator/ 自動ツール] もあります。 |
||
| − | * [https://cipherli.st Cipherli.st] には最新のウェブサーバーのため強固な SSL の設定例とチュートリアルが載っています。 |
||
}} |
}} |
||
| + | {{hc|/etc/nginx/sites-available/example|<nowiki> |
||
| − | ==== nginx ==== |
||
| − | Let's Encrypt の署名済み SSL 証明書を使用するサーバー {{ic|domain.tld}} の例: |
||
| − | |||
| − | {{hc|/etc/nginx/servers-available/domain.tld|<nowiki> |
||
| − | # redirect to https |
||
| − | server { |
||
| − | listen 80; |
||
| − | listen [::]:80; |
||
| − | server_name domain.tld; |
||
| − | return 301 https://$host$request_uri; |
||
| − | } |
||
| − | |||
server { |
server { |
||
listen 443 ssl http2; |
listen 443 ssl http2; |
||
| − | listen [::]:443 ssl http2; |
+ | listen [::]:443 ssl http2; # Listen on IPv6 |
| + | include conf/001-certbot.conf; |
||
| − | ssl_certificate /etc/letsencrypt/live/domain.tld/fullchain.pem; |
||
| − | ssl_certificate_key /etc/letsencrypt/live/domain.tld/privkey.pem; |
||
| − | ssl_trusted_certificate /etc/letsencrypt/live/domain.tld/chain.pem; |
||
| − | ssl_session_timeout 1d; |
||
| − | ssl_session_cache shared:SSL:50m; |
||
| − | ssl_session_tickets off; |
||
| − | ssl_prefer_server_ciphers on; |
||
| − | add_header Strict-Transport-Security max-age=15768000; |
||
| − | ssl_stapling on; |
||
| − | ssl_stapling_verify on; |
||
| − | server_name domain.tld; |
||
.. |
.. |
||
} |
} |
||
| + | </nowiki>}} |
||
| + | === Webroot === |
||
| − | # A subdomain uses the same SSL-certifcate: |
||
| + | {{Note| |
||
| − | server { |
||
| + | * Webroot 方式では Certbot で認証するために'''ポート 80 で HTTP 接続'''できるようにする必要があります。 |
||
| − | listen 443 ssl http2; |
||
| + | * サーバーの名前は DNS と一致している必要があります。 |
||
| − | listen [::]:443 ssl http2; |
||
| + | * {{ic|http://domain.tld/.well-known}} の読み取りを許可するためにホストのパーミッションを修正する必要がある場合があります。 |
||
| − | ssl_certificate /etc/letsencrypt/live/domain.tld/fullchain.pem; |
||
| + | }} |
||
| − | ssl_certificate_key /etc/letsencrypt/live/domain.tld/privkey.pem; |
||
| − | ssl_trusted_certificate /etc/letsencrypt/live/domain.tld/chain.pem; |
||
| − | .. |
||
| − | server_name sub.domain.tld; |
||
| − | .. |
||
| − | } |
||
| + | webroot 方式を使う場合、Certbot クライアントは {{ic|/path/to/domain.tld/html/.well-known/acme-challenge/}} の中でチャレンジ・レスポンス認証を行います。 |
||
| − | # ACME challenge |
||
| − | location ^~ /.well-known { |
||
| − | allow all; |
||
| − | alias /var/lib/letsencrypt/.well-known/; |
||
| − | default_type "text/plain"; |
||
| − | try_files $uri =404; |
||
| − | } |
||
| − | </nowiki>}} |
||
| + | 手動でインストールする場合と比べて、自動で証明書を更新したり楽に管理することができます。ただし、[[#プラグイン]]を使う時のように自動設定・自動インストールはできません。 |
||
| − | === マルチドメイン === |
||
| + | ==== ACME チャレンジリクエストのマッピング ==== |
||
| − | {{ic|/.well-known/acme-challenge/}} への HTTP リクエストを全て一つのフォルダ (例: {{ic|/var/lib/letsencrypt}}) にまとめることで、マルチドメインの管理がとても楽になります。 |
||
| + | |||
| − | |||
| + | {{ic|.well-known/acme-challenge}} に対する HTTP リクエストを全てひとつのディレクトリ (例: {{ic|/var/lib/letsencrypt}}) にマッピングすることで管理が簡単になります。 |
||
| − | Let's Encrypt クライアントのパスから設定したパスに書き込めるように、また、ウェブサーバーから読み込めるようにする必要があります ([[nginx]] や [[Apache]] の場合 ''http'' ユーザー): |
||
| + | |||
| + | Certbot やウェブサーバー (''http'' ユーザーで動作する [[nginx]] や [[Apache]] など) が書き込みできるパスを使用してください: |
||
# mkdir -p /var/lib/letsencrypt/.well-known |
# mkdir -p /var/lib/letsencrypt/.well-known |
||
# chgrp http /var/lib/letsencrypt |
# chgrp http /var/lib/letsencrypt |
||
# chmod g+s /var/lib/letsencrypt |
# chmod g+s /var/lib/letsencrypt |
||
| − | ==== nginx ==== |
+ | ===== nginx ===== |
| − | |||
| − | まず location ブロックを記述したファイルを作成します: |
||
| + | location ブロックを記述したファイルを作成してサーバーブロックから読み込むようにしてください: |
||
{{hc|/etc/nginx/conf.d/letsencrypt.conf|<nowiki> |
{{hc|/etc/nginx/conf.d/letsencrypt.conf|<nowiki> |
||
| − | location ^~ /.well-known { |
+ | location ^~ /.well-known/acme-challenge/ { |
allow all; |
allow all; |
||
| − | + | root /var/lib/letsencrypt/; |
|
default_type "text/plain"; |
default_type "text/plain"; |
||
try_files $uri =404; |
try_files $uri =404; |
||
| 165行目: | 103行目: | ||
</nowiki>}} |
</nowiki>}} |
||
| + | サーバー設定の例: |
||
| − | そして server ブロックの中で作成したファイルを指定します: |
||
{{hc|/etc/nginx/servers-available/domain.conf|<nowiki> |
{{hc|/etc/nginx/servers-available/domain.conf|<nowiki> |
||
server { |
server { |
||
| 174行目: | 112行目: | ||
</nowiki>}} |
</nowiki>}} |
||
| − | ==== Apache ==== |
+ | ===== Apache ===== |
| − | |||
{{ic|/etc/httpd/conf/extra/httpd-acme.conf}} ファイルを作成してください: |
{{ic|/etc/httpd/conf/extra/httpd-acme.conf}} ファイルを作成してください: |
||
| − | |||
{{hc|/etc/httpd/conf/extra/httpd-acme.conf|<nowiki> |
{{hc|/etc/httpd/conf/extra/httpd-acme.conf|<nowiki> |
||
Alias /.well-known/acme-challenge/ "/var/lib/letsencrypt/.well-known/acme-challenge/" |
Alias /.well-known/acme-challenge/ "/var/lib/letsencrypt/.well-known/acme-challenge/" |
||
| 187行目: | 123行目: | ||
</nowiki>}} |
</nowiki>}} |
||
| − | + | {{ic|/etc/httpd/conf/httpd.conf}} で上記ファイルを読み込んでください: |
|
| − | |||
{{hc|/etc/httpd/conf/httpd.conf|<nowiki> |
{{hc|/etc/httpd/conf/httpd.conf|<nowiki> |
||
Include conf/extra/httpd-acme.conf |
Include conf/extra/httpd-acme.conf |
||
</nowiki>}} |
</nowiki>}} |
||
| + | |||
| + | ==== 証明書の取得 ==== |
||
| + | |||
| + | 公開パスとして {{ic|/var/lib/letsencrypt/}} を使用して {{ic|domain.tld}} の証明書を取得するには: |
||
| + | # certbot certonly --email '''email@example.com''' --webroot -w '''/var/lib/letsencrypt/''' -d '''domain.tld''' |
||
| + | |||
| + | (サブ)ドメインを追加するときは、登録済みの全てのドメインを一緒に指定します: |
||
| + | # certbot certonly --email '''email@example.com''' --webroot -w '''/var/lib/letsencrypt/''' -d '''domain.tld,sub.domain.tld''' |
||
| + | |||
| + | 登録している証明書を(全て)更新するには: |
||
| + | # certbot renew |
||
| + | |||
| + | 証明書の更新方法については[[#自動更新]]も参照。 |
||
| + | |||
| + | === 手動 === |
||
| + | |||
| + | ウェブサーバーのプラグインが存在しない場合、以下のコマンドを使ってください: |
||
| + | # certbot certonly --manual |
||
| + | |||
| + | DNS の TXT レコードを利用して認証したい場合、以下のコマンドを使ってください: |
||
| + | # certbot certonly --manual --preferred-challenges dns |
||
| + | |||
| + | 上記のコマンドで自動的にドメインが認証されて秘密鍵と証明書のペアが作成されます。秘密鍵と証明書は {{ic|/etc/letsencrypt/archive/''your.domain''/}} に保存され、{{ic|/etc/letsencrypt/live/''your.domain''/}} からリンクが張られます。 |
||
| + | |||
| + | 証明書が取得できたら手動でウェブサーバーを設定して、シンボリックリンクが存在するディレクトリの秘密鍵・証明書・証明書チェーンを参照してください。 |
||
| + | |||
| + | {{Note|上のコマンドを複数回実行したり証明書を更新したりするとファイル名の末尾に数字が付加されたファイルが {{ic|/etc/letsencrypt/archive/''your.domain''/}} に作られます。Certbot は {{ic|/etc/letsencrypt/live/''your.domain''/}} のシンボリックリンクを自動的に最新のファイルに更新するため、証明書を更新するたびに手動でウェブサーバーの設定を更新する必要はありません。}} |
||
| + | |||
| + | == 高度な設定 == |
||
=== 自動更新 === |
=== 自動更新 === |
||
| 206行目: | 170行目: | ||
ExecStart=/usr/bin/certbot renew --quiet --agree-tos}} |
ExecStart=/usr/bin/certbot renew --quiet --agree-tos}} |
||
| − | プラグインを使 |
+ | プラグインを使わずにウェブサーバーの設定を自動で管理する場合、ウェブサーバーを手動でリロードして証明書が更新されるたびにリロードが必要です。{{ic|ExecStart}} コマンドに {{ic|--deploy-hook "systemctl reload nginx.service"}} を追加することでリロードさせることができます [https://certbot.eff.org/docs/using.html#renewing-certificates]。適宜 {{ic|nginx.service}} のかわりに {{ic|httpd.service}} を使ってください。 |
{{Note|[[systemd/タイマー|タイマー]]を追加する前に、サービスが正しく動作すること、何も入力が要求されないことを確認してください。}} |
{{Note|[[systemd/タイマー|タイマー]]を追加する前に、サービスが正しく動作すること、何も入力が要求されないことを確認してください。}} |
||
| 225行目: | 189行目: | ||
{{ic|certbot.timer}} を[[起動]]・[[有効化]]してください。 |
{{ic|certbot.timer}} を[[起動]]・[[有効化]]してください。 |
||
| − | |||
| − | ==== Standalone を使う場合のサービス ==== |
||
| − | |||
| − | Standalone モードを使用する場合は更新リクエストを実行する前にウェブサーバーを停止させて、更新が完了してからウェブサーバーを再起動するようにします。systemd の ''ExecStartPre'' と ''ExecStartPost'' を使います。 |
||
| − | |||
| − | ===== nginx ===== |
||
| − | |||
| − | {{hc|1=/etc/systemd/system/certbot.service| |
||
| − | 2=[Unit] |
||
| − | Description=Let's Encrypt renewal |
||
| − | |||
| − | [Service] |
||
| − | Type=oneshot |
||
| − | ExecStart=/usr/bin/certbot renew --quiet --agree-tos |
||
| − | ExecStartPre=/bin/systemctl stop nginx.service |
||
| − | ExecStartPost=/bin/systemctl start nginx.service |
||
| − | }} |
||
| − | |||
| − | ===== Apache ===== |
||
| − | |||
| − | {{hc|1=/etc/systemd/system/certbot.service| |
||
| − | 2=[Unit] |
||
| − | Description=Let's Encrypt renewal |
||
| − | |||
| − | [Service] |
||
| − | Type=oneshot |
||
| − | ExecStart=/usr/bin/certbot renew --quiet --agree-tos |
||
| − | ExecStartPre=/bin/systemctl stop httpd.service |
||
| − | ExecStartPost=/bin/systemctl start httpd.service |
||
| − | }} |
||
== 参照 == |
== 参照 == |
||
2018年1月15日 (月) 20:30時点における版
Let’s Encrypt はフリーかつ自動化されたオープンな認証局です。ACME プロトコルを利用しています。
公式クライアントは Certbot という名前で、コマンドラインから有効な X.509 証明書を取得できます。また、手動で CSR 作成を行うミニマルなクライアントを acme-tinyAUR でインストールすることができます。スクリプトで使用するのに適したクライアントとして simp_le-gitAUR や letsencrypt-cliAUR も存在します。
目次
インストール
公式クライアントを用いて発行された証明書はプラグインを使ってウェブサーバーに自動的に設定・インストールできます:
- Nginx 用の実験的なプラグインは certbot-nginx パッケージに入っています。
- Apache HTTP Server 利用時の自動インストールは certbot-apache パッケージで使えます。
設定
証明を作成・インストールする方法は Certbot のドキュメント を参照してください。
プラグイン
Nginx
certbot-nginx プラグインは nginx の server ブロックを自動的に設定します:
# certbot --nginx
証明書を更新するには:
# certbot renew
nginx の設定ファイルに手を加えずに証明書を変更するには:
# certbot --nginx certonly
詳しい情報は Nginx on Arch Linux を見てください。インストールされた証明書の状態を有効に保つ方法は#自動更新を見てください。
サーバーブロックの管理
サーバーブロックを手動で管理する場合、以下のようにサーバーブロックで使うことができます:
/etc/nginx/sites-available/example
server {
listen 443 ssl http2;
listen [::]:443 ssl http2; # Listen on IPv6
ssl_certificate /etc/letsencrypt/live/domain/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/domain/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
..
}
詳しくは nginx#TLS/SSL を見てください。
別の設定ファイルを作成してサーバーブロックから include して使用することも可能です:
/etc/nginx/conf/001-cerbot.conf
ssl_certificate /etc/letsencrypt/live/domain/fullchain.pem; # managed by Certbot ssl_certificate_key /etc/letsencrypt/live/domain/privkey.pem; # managed by Certbot include /etc/letsencrypt/options-ssl-nginx.conf; ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
/etc/nginx/sites-available/example
server {
listen 443 ssl http2;
listen [::]:443 ssl http2; # Listen on IPv6
include conf/001-certbot.conf;
..
}
Webroot
webroot 方式を使う場合、Certbot クライアントは /path/to/domain.tld/html/.well-known/acme-challenge/ の中でチャレンジ・レスポンス認証を行います。
手動でインストールする場合と比べて、自動で証明書を更新したり楽に管理することができます。ただし、#プラグインを使う時のように自動設定・自動インストールはできません。
ACME チャレンジリクエストのマッピング
.well-known/acme-challenge に対する HTTP リクエストを全てひとつのディレクトリ (例: /var/lib/letsencrypt) にマッピングすることで管理が簡単になります。
Certbot やウェブサーバー (http ユーザーで動作する nginx や Apache など) が書き込みできるパスを使用してください:
# mkdir -p /var/lib/letsencrypt/.well-known # chgrp http /var/lib/letsencrypt # chmod g+s /var/lib/letsencrypt
nginx
location ブロックを記述したファイルを作成してサーバーブロックから読み込むようにしてください:
/etc/nginx/conf.d/letsencrypt.conf
location ^~ /.well-known/acme-challenge/ {
allow all;
root /var/lib/letsencrypt/;
default_type "text/plain";
try_files $uri =404;
}
サーバー設定の例:
/etc/nginx/servers-available/domain.conf
server {
server_name domain.tld
..
include conf.d/letsencrypt.conf;
}
Apache
/etc/httpd/conf/extra/httpd-acme.conf ファイルを作成してください:
/etc/httpd/conf/extra/httpd-acme.conf
Alias /.well-known/acme-challenge/ "/var/lib/letsencrypt/.well-known/acme-challenge/"
<Directory "/var/lib/letsencrypt/">
AllowOverride None
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
Require method GET POST OPTIONS
</Directory>
/etc/httpd/conf/httpd.conf で上記ファイルを読み込んでください:
/etc/httpd/conf/httpd.conf
Include conf/extra/httpd-acme.conf
証明書の取得
公開パスとして /var/lib/letsencrypt/ を使用して domain.tld の証明書を取得するには:
# certbot certonly --email email@example.com --webroot -w /var/lib/letsencrypt/ -d domain.tld
(サブ)ドメインを追加するときは、登録済みの全てのドメインを一緒に指定します:
# certbot certonly --email email@example.com --webroot -w /var/lib/letsencrypt/ -d domain.tld,sub.domain.tld
登録している証明書を(全て)更新するには:
# certbot renew
証明書の更新方法については#自動更新も参照。
手動
ウェブサーバーのプラグインが存在しない場合、以下のコマンドを使ってください:
# certbot certonly --manual
DNS の TXT レコードを利用して認証したい場合、以下のコマンドを使ってください:
# certbot certonly --manual --preferred-challenges dns
上記のコマンドで自動的にドメインが認証されて秘密鍵と証明書のペアが作成されます。秘密鍵と証明書は /etc/letsencrypt/archive/your.domain/ に保存され、/etc/letsencrypt/live/your.domain/ からリンクが張られます。
証明書が取得できたら手動でウェブサーバーを設定して、シンボリックリンクが存在するディレクトリの秘密鍵・証明書・証明書チェーンを参照してください。
高度な設定
自動更新
systemd
certbot.service ユニットを作成:
/etc/systemd/system/certbot.service
[Unit] Description=Let's Encrypt renewal [Service] Type=oneshot ExecStart=/usr/bin/certbot renew --quiet --agree-tos
プラグインを使わずにウェブサーバーの設定を自動で管理する場合、ウェブサーバーを手動でリロードして証明書が更新されるたびにリロードが必要です。ExecStart コマンドに --deploy-hook "systemctl reload nginx.service" を追加することでリロードさせることができます [1]。適宜 nginx.service のかわりに httpd.service を使ってください。
それから、タイマーを追加することで証明書を更新できます (更新の必要がない証明書は自動的にスキップされます)。
/etc/systemd/system/certbot.timer
[Unit] Description=Daily renewal of Let's Encrypt's certificates [Timer] OnCalendar=0/12:00:00 RandomizedDelaySec=1h Persistent=true [Install] WantedBy=timers.target