#author("2023-08-29T02:36:26+00:00","default:iseki","iseki") #author("2025-08-11T05:25:42+00:00","default:iseki","iseki") * Let’s Encrypt [#be335664] ** certbot [#q7d2a70f] ** [[certbot]] [#q7d2a70f] - Let's ncrypt のサーバ証明書の自動発行・更新用スクリプト *** Install [#odbcf85c] # yum install epel-release # yum install certbot **** CentOS6 [#u2bfa592] - certbot-auto -- 最新版は動かない(2021 6/29) -- 古いバージョンの certbot-auto をダウンロード # /usr/local/sbin # wget https://raw.githubusercontent.com/certbot/certbot/v1.9.0/certbot-auto -- スクリプト /usr/local/sbin/certbot を作る #!/bin/bash /usr/local/sbin/certbot-auto $* --no-self-upgrade --no-bootstrap - python3.6 -- python3 が必要だがダウンロードできないので,ソースからコンパイルする. # wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tar.xz # xzcat Python-3.6.2.tar.xz | tar xfv - # cd Python-3.6.2 # ./configure # make # make install *** 実行 [#wb966ce8] - certbot certonly --webroot -w /home/apache/htdocs -d www.nsl.tuis.ac.jp -- DocumentRoot にファイルを作って,サーバでそれをチェックしているみたい(サーバの存在確認) --- メールアドレス,Y,Y - サーバ証明書と秘密鍵が以下にできる.(シンボリックリンク) -- 証明書:/etc/letsencrypt/live/www.nsl.tuis.ac.jp/fullchain.pem -- 秘密鍵:/etc/letsencrypt/live/www.nsl.tuis.ac.jp/privkey.pem *** cron [#o6968d67] **** 失敗 [#ybbf8460] - %%月一または週一%% 毎日で以下の cronを流す. -- %%00 3 * * * /usr/bin/certbot renew 1>/dev/null 2>&1 && /etc/init.d/httpd restart 1>/dev/null 2>&1%% -- これだと 更新が無い場合も httpd が再起動する. **** 正解は以下 [#l9205dc3] - cron 00 3 * * * /usr/local/sbin/certbot renew --post-hook "/etc/init.d/httpd restart" 1>/dev/null 2>&1 **** for Jupyterhub [#i691e1cc] 05 4 * * * /usr/bin/certbot renew --post-hook "touch /tmp/certs_changed" 1>/dev/null 2>&1 && /usr/local/bin/restart-network-service 1>/dev/null 2>&1 - /usr/local/bin/restart-network-service #!/bin/bash # if [ ! -f /tmp/certs_changed ]; then exit 1 fi rm /tmp/certs_changed # #systemctl restart cockpit # systemctl restart ltictr_proxy sleep 1 systemctl restart jupyterhub # ** GitLab [#o17b206c] - see [[GitLab]]