YOGYUI

Let's Encrypt SSL 인증서 갱신(renew) 중 webroot 문제 발생 시 해결 방법 본문

홈네트워크(IoT)/일반

Let's Encrypt SSL 인증서 갱신(renew) 중 webroot 문제 발생 시 해결 방법

요겨 2022. 8. 24. 15:14
반응형

Resolve webroot error when renewing SSL certificate (Let's Encrypt)

Let's Encrypt로 발급받은 SSL 인증서는 3개월에 한번씩 갱신해줘야 한다

https://eff-certbot.readthedocs.io/en/stable/using.html

※ e-mail 주소를 기입해주면 인증서 만료 기한이 다가올 때 메일로도 통보해준다 (17일 남았을 때 최초로 메일 수신)

인증서 만료 9일 남았을 때의 이메일 통보

 

1. 문제

Let's Encrypt SSL 인증서는 certbot 툴로 관리(발급, 갱신, 폐기 등)하며, 인증서 갱신은 renew 인자를 명령어에 붙이면 된다

(특별한 경우가 아니라면 certbot에서 제공하는 auto renewal, 자동 갱신 기능을 사용하는게 좋다)

$ sudo certbot renew

최근에 홈네트워크 플랫폼 Home Assistant의 HTTPS 접근을 위해 발급받은 SSL을 갱신하려고 하니 다음과 같은 오류와 함께 진행이 되지 않아 해결법을 알아보았다

오류메시지는 다음과 같았다

Attempting to renew cert (xxxx.duckdns.org) from /etc/letsencrypt/renewal/xxxx.duckdns.org.conf produced an unexpected error:
Missing command line flag or config entry for this setting:
Input the webroot for xxxx.duckdns.org:. Skipping.
All renewal attempts failed. The following certs could not be renewed: /etc/letsencrypt/live/xxxx.duckdns.org/fullchain.pem (failure)

오류 메시지 핵심: 갱신을 위한 설정파일(conf) 내에 webroot 정보가 빠져있다

2. 해결

설정파일을 nano나 vim같은 텍스트 에디터로 연 뒤 webroot 정보를 기입해주면 된다

$ sudo nano /etc/letsencrypt/renewal/xxxx.duckdns.org.conf

파일을 열어보니

# renew_before_expiry = 30 days
version = 0.31.0
archive_dir = /etc/letsencrypt/archive/xxxx.duckdns.org
cert = /etc/letsencrypt/live/xxxx.duckdns.org/cert.pem
privkey = /etc/letsencrypt/live/xxxx.duckdns.org/privkey.pem
chain = /etc/letsencrypt/live/xxxx.duckdns.org/chain.pem
fullchain = /etc/letsencrypt/live/xxxx.duckdns.org/fullchain.pem

# Options used in the renewal process
[renewalparams]
account = xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
authenticator = webroot
webroot_path = /var/www/letsencrypt,
server = https://acme-v02.api.letsencrypt.org/directory
[[webroot_map]]

[[webroot_map]] 아래에 아무 항목도 기입되어 있지 않았다

아래에 다음과 같이 도메인 주소에 대한 정보를 기입해주고 저장해주자

※ [renewalparams]의 webroot_path와 동일한 경로를 지정해주면 된다

[[webroot_map]]
xxxx.duckdns.org = /var/www/letsencrypt

다시 renew를 실행해보니

문제없이 갱신이 진행된다 ㅎㅎ

위의 내용은 ipTime 공유기를 외부에서 접근하기 위해 duckdns로 무료 도메인을 발급받은 뒤, 라즈베리파이에서 SSL 인증서를 발급받은 환경에서 작성되었다
인증서 최초 발급에 대한 내용은 링크를 참고 (certbot 설치 등)

끝~!

 

[참고]

https://community.letsencrypt.org/t/auto-renewal-started-failing-with-error-missing-command-line-flag-or-config-entry-for-this-setting/111211/3

반응형
Comments