| ページ一覧 | ブログ | twitter |  書式 | 書式(表) |

MyMemoWiki

Apache SSL

提供: MyMemoWiki
ナビゲーションに移動 検索に移動

Apache SSL

Apache

Let's Encrypt

https://weblabo.oscasierra.net/letsencrypt-2/

  • Let's Encrypt の証明書導入
    • Let’s Encrypt における証明書発行の手順はほとんどが自動化されている。
    • Let’s Encrypt のサーバーと、Certbot クライアントソフトウェアにより自動化されている。
    • 最初にすべきことは、証明書を設定しようとしているマシンに Certbot クライアントをインストール
    • Certbot クライアントが、 Let’s Encrypt のサーバーとやり取りすることで証明書の発行と設定を自動的に行ってくれる
    • 発行される証明書は、いわゆる「DV証明書」という種類の証明
    • Let’s Encrypt サーバーは、発行する証明書の対象のドメインの所有者自身が発行要求をしてきたことを確認した上で、SSL/TLSサーバー証明書を発行
    • 証明書の発行を要求された Let’s Encrypt サーバーは、発行しようとしている証明書のドメインの80番ポートにアクセスし、特定の内容のファイルが存在していることを確認
    • ファイルが取得できればドメインの所有者が発行要求を出していることを確認できまる

Certbot クライアントをインストール

  1. # yum install epel-release
  2. # yum install certbot python-certbot-apache

SSL/TLS証明書の作成

  • -w DocumentRoot : /var/www/html/
  • -d domain
  1. # certbot certonly --webroot -w /var/www/html/ -d repo.typea.info
  • 対話的に設定を行う
  1. certbot certonly --webroot -w /var/www/html/ -d repo.typea.info
  2. Saving debug log to /var/log/letsencrypt/letsencrypt.log
  3. Plugins selected: Authenticator webroot, Installer None
  4. Starting new HTTPS connection (1): acme-v02.api.letsencrypt.org
  5. Obtaining a new certificate
  6. Performing the following challenges:
  7. http-01 challenge for repo.typea.info
  8. Using the webroot path /var/www/html for all unmatched domains.
  9. Waiting for verification...
  10. Cleaning up challenges
  11.  
  12. IMPORTANT NOTES:
  13. - Congratulations! Your certificate and chain have been saved at:
  14. /etc/letsencrypt/live/repo.typea.info/fullchain.pem
  15. Your key file has been saved at:
  16. /etc/letsencrypt/live/repo.typea.info/privkey.pem
  17. Your cert will expire on 2020-07-25. To obtain a new or tweaked
  18. version of this certificate in the future, simply run certbot
  19. again. To non-interactively renew *all* of your certificates, run
  20. "certbot renew"
  21. - If you like Certbot, please consider supporting our work by:
  22.  
  23. Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
  24. Donating to EFF: https://eff.org/donate-le
  • サーバー証明書が作成された
  1. # ls -l /etc/letsencrypt/live/repo.typea.info/
  2. 合計 4
  3. -rw-r--r-- 1 root root 692 4 26 11:39 README
  4. lrwxrwxrwx 1 root root 39 4 26 11:39 cert.pem -> ../../archive/repo.typea.info/cert1.pem
  5. lrwxrwxrwx 1 root root 40 4 26 11:39 chain.pem -> ../../archive/repo.typea.info/chain1.pem
  6. lrwxrwxrwx 1 root root 44 4 26 11:39 fullchain.pem -> ../../archive/repo.typea.info/fullchain1.pem
  7. lrwxrwxrwx 1 root root 42 4 26 11:39 privkey.pem -> ../../archive/repo.typea.info/privkey1.pem
  • /etc/httpd/conf.d/ssl.conf
  1. SSLCertificateFile /etc/letsencrypt/live/repo.typea.info/cert.pem
  2. SSLCertificateKeyFile /etc/letsencrypt/live/repo.typea.info/privkey.pem
  3. SSLCertificateChainFile /etc/letsencrypt/live/repo.typea.info/chain.pem

証明書自動更新

  1. # crontab -u root -e
  2. 00 03 01 * * certbot renew && systemctl restart httpd


サブドメインも対応

  1. # certbot certonly --webroot -w /var/www/html/ -d typea.info -d www.typea.info
  1. Saving debug log to /var/log/letsencrypt/letsencrypt.log
  2. Plugins selected: Authenticator webroot, Installer None
  3. Starting new HTTPS connection (1): acme-v02.api.letsencrypt.org
  4.  
  5. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  6. You have an existing certificate that contains a portion of the domains you
  7. requested (ref: /etc/letsencrypt/renewal/www.typea.info.conf)
  8.  
  9. It contains these names: www.typea.info
  10.  
  11. You requested these names for the new certificate: typea.info, www.typea.info.
  12.  
  13. Do you want to expand and replace this existing certificate with the new
  14. certificate?
  15. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  16. (E)xpand/(C)ancel: E
  17. Renewing an existing certificate
  18. Performing the following challenges:
  19. http-01 challenge for typea.info
  20. Using the webroot path /var/www/html for all unmatched domains.
  21. Waiting for verification...
  22. Cleaning up challenges
  23.  
  24. IMPORTANT NOTES:
  25. - Congratulations! Your certificate and chain have been saved at:
  26. /etc/letsencrypt/live/www.typea.info/fullchain.pem
  27. Your key file has been saved at:
  28. /etc/letsencrypt/live/www.typea.info/privkey.pem
  29. Your cert will expire on 2020-07-24. To obtain a new or tweaked
  30. version of this certificate in the future, simply run certbot
  31. again. To non-interactively renew *all* of your certificates, run
  32. "certbot renew"
  33. - If you like Certbot, please consider supporting our work by:
  34.  
  35. Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
  36. Donating to EFF: https://eff.org/donate-le