Let’ Encrypt を使用して、SSL証明書の自動更新もしてしまおうと、こちらのサイト(https://centossrv.com/apache-certbot.shtml)を参考に設定していたところ、
スポンサーリンク
An unexpected error occurred: Bug in pythondialog: expected an empty output from u'infobox', but got: u'Error opening terminal: unknown.\n'Please see the logfile 'certbot.log' for more details.
こんなエラーが発生しました。
しょうがないのでログファイルを漁ってみたところ、
Traceback (most recent call last): File "/root/.local/share/letsencrypt/bin/letsencrypt", line 11, insys.exit(main()) File "/root/.local/share/letsencrypt/lib/python2.7/site-packages/certbot/main.py", line 749, in main setup_logging(config) File "/root/.local/share/letsencrypt/lib/python2.7/site-packages/certbot/main.py", line 653, in setup_logging logger.info("Saving debug log to %s", log_file_path) File "/usr/lib64/python2.7/logging/__init__.py", line 1149, in info self._log(INFO, msg, args, **kwargs) File "/usr/lib64/python2.7/logging/__init__.py", line 1268, in _log self.handle(record) File "/usr/lib64/python2.7/logging/__init__.py", line 1278, in handle self.callHandlers(record) File "/usr/lib64/python2.7/logging/__init__.py", line 1318, in callHandlers hdlr.handle(record) File "/usr/lib64/python2.7/logging/__init__.py", line 749, in handle self.emit(record) File "/root/.local/share/letsencrypt/lib/python2.7/site-packages/certbot/log.py", line 64, in emit self.width + self.PADDING_WIDTH) File "/root/.local/share/letsencrypt/lib/python2.7/site-packages/dialog.py", line 2675, in infobox kwargs) File "/root/.local/share/letsencrypt/lib/python2.7/site-packages/dialog.py", line 1765, in _widget_with_no_output widget_name, output)) PythonDialogBug
こんなログがありましたので、色々と見てみたのですが、原因に辿り着くことができず。
しかし、ターミナル上でスクリプトを実行しても特にエラーは発生せずに正常に更新されます。
仕方ないので、certbot-auto のコマンドオプションとにらめっこして、参考にさせていただいたサイトのサーバー証明書自動更新設定スクリプトを修正してみました。
#!/bin/sh log=`mktemp` code=0 # # 証明書更新 # for conf in `ls /etc/letsencrypt/renewal/` do # ドメイン名取得 domain=`echo ${conf}|sed -e 's/\([^ ]*\)\.conf/\1/p' -e d` # 認証方式取得 authenticator=`grep authenticator /etc/letsencrypt/renewal/${conf}|awk '{print $3}'` if [ ${authenticator} = 'webroot' ]; then # Web認証の場合 # ドキュメントルート取得 webroot=`grep -A 1 webroot_map /etc/letsencrypt/renewal/${conf}|grep =|awk '{print $3}'` # 証明書更新 /usr/local/certbot/certbot-auto certonly --webroot \ ---non-interactive ---text \ -w ${webroot} -d ${domain} --renew-by-default >> ${log} 2>&1 [ $? -ne 0 ] && cat ${log} else # スタンドアロン認証の場合 # 証明書更新 lsof -i:80 > /dev/null 2>&1 if [ $? -eq 0 ]; then echo 'Webサーバー稼働中のためスタンドアロン認証不可' else /usr/local/certbot/certbot-auto certonly -a standalone \ ---non-interactive ---text \ -d ${domain} --renew-by-default >> ${log} 2>&1 [ $? -ne 0 ] && cat ${log} fi fi done # # 証明書更新反映 # # Webサーバー設定再読込み lsof -i:443 > /dev/null 2>&1 if [ $? -eq 0 ]; then rpm -q systemd > /dev/null 2>&1 if [ $? -eq 0 ]; then systemctl reload httpd else /etc/rc.d/init.d/httpd reload > /dev/null 2>&1 fi fi # SMTPサーバー設定再読込み lsof -i:465 > /dev/null 2>&1 if [ $? -eq 0 ]; then rpm -q systemd > /dev/null 2>&1 if [ $? -eq 0 ]; then systemctl reload postfix else /etc/rc.d/init.d/postfix reload > /dev/null 2>&1 fi fi # IMAPサーバー設定再読込み lsof -i:995 > /dev/null 2>&1 if [ $? -eq 0 ]; then rpm -q systemd > /dev/null 2>&1 if [ $? -eq 0 ]; then systemctl reload dovecot else /etc/rc.d/init.d/dovecot reload > /dev/null 2>&1 fi fi # # ログをsyslogへ出力後削除 # cat ${log}|logger -t `basename ${0}` ; rm -f ${log}
変更点は、certbot-auto のコマンドオプションに –non-interactive –text の2つを追記しました。
一応 –dry-run オプションを追加してcronでの動作確認をしましたが、うまく動くようでした。
これで、正常にSSL証明書が更新されるようになったはずです。
- 投稿タグ
- certbot-auto, Let's Encrypt, python, SSL証明書
最近のコメント