page counter next up previous contents
Next: Certbot 0.33.1 Up: Let's Encrypt Previous: Let's Encrypt 憑證更新   Contents   DYWANG_HOME

Certbot

  1. Let's Encrypt 已不用上網申請,等通過審查。手動上網下載憑證教學參考,但架設 https 及 憑證放置目錄要手動設定。
  2. 憑證下載及更新程式由原 letencrypt-auto 已改成 certbot 自動程式負責,先下載 certbot-auto 程式。
    [root@dns bin]# mkdir certbot
    [root@dns bin]# cd certbot
    [root@dns certbot]# wget --no-check-certificate https://dl.eff.org/certbot-auto
    [root@dns certbot]# chmod +x certbot-auto
    
  3. *執行 certbot-auto 出現找不到 apache2ctl 程式的錯誤,但 CentOS 6 只有 apachectl 指令。
    [root@dns certbot]# ./certbot-auto --apache
    Saving debug log to /var/log/letsencrypt/letsencrypt.log
    Failed to find executable apache2ctl in expanded PATH: /tmp/product:/tmp/updates:/usr/bin:/bin:
    /sbin:/usr/sbin:/mnt/sysimage/bin:/mnt/sysimage/usr/bin:/mnt/sysimage/usr/sbin:/mnt/sysimage/sbin:
    /mnt/sysimage/usr/X11R6/bin:/sbin:/usr/sbin:/root/bin:/root/bin:/usr/local/bin:/usr/local/sbin
    The apache plugin is not working; there may be problems with your existing configuration.
    The error was: NoInstallationError('Cannot find Apache control command apache2ctl',)
    
  4. *以 apachectl 代替 apache2ctl,再執行 certbot-auto 出現 apache 設定錯誤。
    [root@dns certbot]# ln -s /usr/sbin/apachectl /usr/sbin/apache2ctl 
    [root@dns certbot]# ./certbot-auto --apache -d web.csie.cyut.edu.tw
    Saving debug log to /var/log/letsencrypt/letsencrypt.log
    The apache plugin is not working; there may be problems with your existing configuration.
    The error was: NoInstallationError('Could not find configuration root',)
    
  5. 因為 cert-auto 使用的 python 最小版本是 2.7,所以必須先安裝 python2.7 相關套件 (參考20.3)。
    [root@dywang certbot]# yum install -y python27-libs python27 \
    python27-virtualenv python27-tools python27-pip
    
  6. 如果使用 DYW 6 Linux,必須確認有 /etc/redhat-release 作業系統的版本檔。沒有的話,必須做以下連結。
    [root@dywang certbot]# cd /etc/
    [root@dywang etc]# ln -s dywang-release redhat-release
    [root@dywang etc]# cd -
    
  7. 如果執行 certbot-auto 時 virtualenv 還是使用 2.6 版,可以修改 1005 行的 virtualenv 命令為 virtualenv-2.7。
    [root@dywang certbot]# grep 'virtualenv --no-site-packages' certbot-auto
      VIRTUALENV_NO_DOWNLOAD=1 virtualenv --no-site-packages --python "$LE_PYTHON" "$VENV_PATH"
      VIRTUALENV_NO_DOWNLOAD=1 virtualenv --no-site-packages --python "$LE_PYTHON" "$VENV_PATH" \
    [root@dywang certbot]# sed -i 's/\(virtualenv\)\( --no-site-packages\)/\1-2.7\2/' certbot-auto
    [root@dywang certbot]# grep 'virtualenv.*--no-site-packages' certbot-auto
      VIRTUALENV_NO_DOWNLOAD=1 virtualenv-2.7 --no-site-packages --python "$LE_PYTHON" "$VENV_PATH"
      VIRTUALENV_NO_DOWNLOAD=1 virtualenv-2.7 --no-site-packages --python "$LE_PYTHON" "$VENV_PATH" \
    
  8. 因為 CentOS 6 apache 版本不滿足 certbot,改用 webroot 方式下載憑證,下載成功後提示憑證放在 /etc/letsencrypt/live/web.csie.cyut.edu.tw 目錄下。
    [root@dns certbot]# ./certbot-auto --webroot -w /var/www/html -d web.csie.cyut.edu.tw certonly
    Saving debug log to /var/log/letsencrypt/letsencrypt.log
    Plugins selected: Authenticator webroot, Installer None
    Obtaining a new certificate
    Performing the following challenges:
    http-01 challenge for web.csie.cyut.edu.tw
    Using the webroot path /var/www/html for all unmatched domains.
    Waiting for verification...
    Cleaning up challenges
    
    IMPORTANT NOTES:
     - Congratulations! Your certificate and chain have been saved at:
       /etc/letsencrypt/live/web.csie.cyut.edu.tw/fullchain.pem
       Your key file has been saved at:
       /etc/letsencrypt/live/web.csie.cyut.edu.tw/privkey.pem
       Your cert will expire on 2018-01-22. To obtain a new or tweaked
       version of this certificate in the future, simply run certbot-auto
       again. To non-interactively renew *all* of your certificates, run
       "certbot-auto renew"
     - 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
    
  9. 查看 /etc/letsencrypt/live/web.csie.cyut.edu.tw 目錄下的檔案。
    [root@dns ~]# ll /etc/letsencrypt/live/web.csie.cyut.edu.tw/
    total 4
    lrwxrwxrwx. 1 root root  49 Oct 24 11:40 cert.pem -> ../../archive/web.csie.cyut.edu.tw/cert1.pem
    lrwxrwxrwx. 1 root root  50 Oct 24 11:40 chain.pem -> ../../archive/web.csie.cyut.edu.tw/chain1.pem
    lrwxrwxrwx. 1 root root  54 Oct 24 11:40 fullchain.pem -> ../../archive/web.csie.cyut.edu.tw/fullchain1.pem
    lrwxrwxrwx. 1 root root  52 Oct 24 11:40 privkey.pem -> ../../archive/web.csie.cyut.edu.tw/privkey1.pem
    -rw-r--r--. 1 root root 543 Oct 24 11:40 README
    
  10. 編輯 ssl.conf 並重新載入。
    [root@dns renewal]# vim /etc/httpd/conf.d/ssl.conf
    [root@dns renewal]# grep ^SSLCert /etc/httpd/conf.d/ssl.conf
    SSLCertificateFile /etc/letsencrypt/live/web.csie.cyut.edu.tw/cert.pem  
    SSLCertificateKeyFile /etc/letsencrypt/live/web.csie.cyut.edu.tw/privkey.pem
    SSLCertificateChainFile /etc/letsencrypt/live/web.csie.cyut.edu.tw/chain.pem    
    [root@dns renewal]# /etc/init.d/httpd reload
    
  11. httpd 服務重新載入設定。
    [root@dns certbot]# /etc/init.d/httpd reload
    
  12. certbot-auto 使用 renew 命令選項,更新憑證。
    [root@dns certbot]# ./certbot-auto renew
    



De-Yu Wang 2020-05-19