letsencrypt ssl인증서 만료 갱신 오류 해결 - webroot 관련

ssl인증서는 최근 웹서비스에서는 필요불가결한 서비스이다.

여러 웹서비스를 운영할 경우 상당히 많은 부분에 ssl 인증서가 필요하다 보니 비용 문제에 직면하게 된다.

 

그래서, 무료로 사용이 가능한 letsencrypt 인증서를 많이들 사용하는데....

잘만 관리해주면 상당히 괞찮은 ssl 적용 방법이라고 생각된다.

 

다만, 가끔씩 갱신이 잘 안된다거나, 갱신 오류가 발생하기도 하는데...

오늘은 아래와 같은 오류에 대해서 해결하는 방법을 공유해 본다.

 

 

letsencrypt ssl 인증서 갱신하기

 

우선, 인증서를 적용하는 도메인을 aaaa.bbbb.kr 이라고 가정하고..

 

리눅스 크론탭(crontab)에 통해 매달 2일정도 갱신을 시도하도록 스케줄링을 적용해 놓았다.

# letsencrypt renew
00 5 10,16 * * root /root/letsencrypt/certbot-auto renew >> /var/log/letsencrypt/renew.log

 

그런데, 확인을 해보니, 인증서 만료일이 갱신되지 못하고 실패가 나고 있었다.

그래서, 직접 갱신 시도를 해보았다.

 

#cd /root/letsencrypt

#./certbot-auto renew

 

갱신을 실행해 보니, 아래와 같은 메세지가 출력되었다.

 

Saving debug log to /var/log/letsencrypt/letsencrypt.log

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing /etc/letsencrypt/renewal/aaaa.bbbb.kr.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cert is due for renewal, auto-renewing...
Plugins selected: Authenticator webroot, Installer None
Renewing an existing certificate
Performing the following challenges:
http-01 challenge for aaaa.bbbb.kr
Cleaning up challenges
Attempting to renew cert (aaaa.bbbb.kr) from /etc/letsencrypt/renewal/aaaa.bbbb.kr.conf produced an unexpected error: Missing command line flag or config entry for this setting:
Input the webroot for aaaa.bbbb.kr:. Skipping.
All renewal attempts failed. The following certs could not be renewed:
  /etc/letsencrypt/live/aaaa.bbbb.kr/fullchain.pem (failure)

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

All renewal attempts failed. The following certs could not be renewed:
  /etc/letsencrypt/live/aaaa.bbbb.kr/fullchain.pem (failure)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1 renew failure(s), 0 parse failure(s)

 

내용을 보니, 뭔가 수정을 하라는거 같은데....

오류 내용에 뭔가 빠져 있다고 하는거 같고... 그게 webroot 와 관련되는거 같고...

그래서 구글링을 통해 확인을 해보니...

configuration 파일(/etc/letsencrypt//renewal/aaaa.bbbb.kr.conf)에 webroot 정보가 빠져서 그렇다고 한다.

 

설정파일을 열어 확인해보니, 해당 부분이 없서 추가 해주었다.

 

#vi /etc/letsencrypt/renewal/aaaa.bbbb.kr.conf

# renew_before_expiry = 30 days
version = 0.38.0
archive_dir = /etc/letsencrypt/archive/aaaa.bbbb.kr
cert = /etc/letsencrypt/live/aaaa.bbbb.kr/cert.pem
privkey = /etc/letsencrypt/live/aaaa.bbbb.kr/privkey.pem
chain = /etc/letsencrypt/live/aaaa.bbbb.kr/chain.pem
fullchain = /etc/letsencrypt/live/aaaa.bbbb.kr/fullchain.pem

# Options used in the renewal process
[renewalparams]
server = https://acme-v02.api.letsencrypt.org/directory
authenticator = webroot
account = asdfasfasfasfdasfdasfdasfdasdfa

 

설정 파일 내용을 보면, webroot에 대한 정보가 없다.

그래서, aaaa.bbbb.kr 에 대한 웹루트(/webroot/aaaa.bbbb.kr) 정보를 설정 파일 하단에 추가 주었다.

 

[[webroot_map]]
aaaa.bbbb.kr = /webroot/aaaa.bbbb.kr

 

 

이렇게 수정을 마치고, 다시 갱신 시도를 해보니 오류 없이 잘 되었다.

 

#./certbot-auto renew

 

Saving debug log to /var/log/letsencrypt/letsencrypt.log

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing /etc/letsencrypt/renewal/aaaa.bbbb.kr.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cert is due for renewal, auto-renewing...
Plugins selected: Authenticator webroot, Installer None
Renewing an existing certificate
Performing the following challenges:
http-01 challenge for aaaa.bbbb.kr
Waiting for verification...
Cleaning up challenges

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
new certificate deployed without reload, fullchain is
/etc/letsencrypt/live/aaaa.bbbb.kr/fullchain.pem
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Congratulations, all renewals succeeded. The following certs have been renewed:
  /etc/letsencrypt/live/aaaa.bbbb.kr/fullchain.pem (success)