lets encrypt 인증서 갱신 실패

프로그래밍/서버2020. 4. 20. 13:06

crontab을 이용해서 인증서를 자동 갱신하도록 만들어놨는데.. 오늘 확인해보니 인증서가 갱신이 되지 않았습니다.

 

sudo certbot renew --renew-hook "sudo /opt/bitnami/ctlscript.sh restart apache"

 

위와 같이 갱신 명령어를 직접 입력해보니 아래의 에러가 발생했습니다.

 

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

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing /etc/letsencrypt/renewal/xxx.com.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cert is due for renewal, auto-renewing...
Could not choose appropriate plugin: The manual plugin is not working; there may be problems with your existing configuration.
The error was: PluginError('An authentication script must be provided with --manual-auth-hook when using the manual plugin non-interactively.',)
Attempting to renew cert (xxx.com) from /etc/letsencrypt/renewal/xxx.com.conf produced an unexpected error: The manual plugin is not working; there may be problems with your existing configuration.
The error was: PluginError('An authentication script must be provided with --manual-auth-hook when using the manual plugin non-interactively.',). Skipping.
All renewal attempts failed. The following certs could not be renewed:
  /etc/letsencrypt/live/xxx.com/fullchain.pem (failure)

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

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

 

 

자료를 좀 찾아보니 아래의 내용이 있네요.

(https://github.com/certbot/certbot/issues/7489)

Certificates that are created using --manual (and without an authentication hook) cannot be automatically renewed. This is because it involves you performing the the authorization steps by hand, which is not something that Certbot can automatically repeat at renewal time.

Usually you will want to use an authenticator other than the manual one (such as --apache, --nginx, --webroot, --standalone), so that Certbot can perform automatic renewal.

If you want to perform the manual authorization process again, then you will need to repeat the original command you used. For example:

 

certbot certonly --manual -d domain.dev

 

If you would like further help with getting renewal working, please create a thread on https://community.letsencrypt.org .

아무래도.. 제가 인증서를 처음 만들 때 --manual 명령어를 써서 만든 것 같습니다;;

 

서버의 /var/log/letsencrypt 경로에서 최초의 로그를 확인해봤습니다.

2020-01-28 09:39:13,773:DEBUG:certbot.main:certbot version: 0.31.0
2020-01-28 09:39:13,774:DEBUG:certbot.main:Arguments: ['-d', 'xxx.com', '-d', '*.xxx.com', '--manual', '--preferred-challenges', 'dns']
2020-01-28 09:39:13,774:DEBUG:certbot.main:Discovered plugins: PluginsRegistry(PluginEntryPoint#manual,PluginEntryPoint#null,PluginEntryPoint#standalone,PluginEntryPoint#webroot)
2020-01-28 09:39:13,784:DEBUG:certbot.log:Root logging level set at 20
2020-01-28 09:39:13,784:INFO:certbot.log:Saving debug log to /var/log/letsencrypt/letsencrypt.log
2020-01-28 09:39:13,785:DEBUG:certbot.plugins.selection:Requested authenticator manual and installer None
2020-01-28 09:39:13,786:DEBUG:certbot.plugins.selection:Single candidate plugin: * manual
Description: Manual configuration or run your own shell scripts
Interfaces: IAuthenticator, IPlugin
Entry point: manual = certbot.plugins.manual:Authenticator
Initialized: <certbot.plugins.manual.Authenticator object at 0x7f7adb626048>

잘은 몰라도.. --manual 명령어를 써서 만든 게 맞는 것 같네요. ㅡ.ㅡ;; 구글에서 어느 블로그 따라해서 만들었었는데 흠..

 

자료를 좀 더 찾아봤습니다.

https://serverfault.com/questions/750902/how-to-use-lets-encrypt-dns-challenge-validation

 

certbot -d bristol3.pki.enigmabridge.com --manual --preferred-challenges dns certonly

제가 이 서버에서 인증서를 발급 받을 때.. 위와 같은 명령어를 쓴 것 같네요.

 

그리고 인증서 발급받는 과정에서

DNS 검증을 위해.. 위와 같은 DNS TXT 레코드를 추가하는 과정을 했었나봅니다.. ㅎㅎ 

 

 

흠.. 자료를 좀 찾아보니 wildcard certificate 측.. *.xxx.com과 같은 주소로 인증서를 발급 받으려면.. manual로 인증서를 발급 받아야 하는 것 같습니다.

https://github.com/certbot/certbot/issues/6280#issuecomment-451361955

Most people use --manual because they need a wildcard certificate. If you don't need a wildcard certificate, you should most likely use a different authenticator, like --apache, --nginx, --webroot, or --standalone, depending on your needs. The other authenticators are much easier to use and support automated renewal out of the box (except for --standalone on systems where there's also an existing web server listening on port 80).

If you do need a wildcard certificate, the trouble is that you need to update your DNS records by posting new _acme-challege TXT records every time the certificate is renewed. Certbot isn't capable of doing this itself unless you give it some kind of code and credentials that will allow it to make changes to your DNS records; there's no general-purpose way of doing this that would work in every environment.

인증서를 갱신할 때.. 문제가 생긴 이유는 TXT records 역시 갱신을 해야하는데.. 이건 certbot이 못하기 때문입니다. 뭐 다른 플러그인을 쓰거나 그래야 하는 것 같은데.. ㅎㅎ;; 좀 복잡한 것 같네요.

 

저의 경우는 사실 wildcard certificate를 쓸 필요가 없는데 일반 webroot? certificate로 다시 받을 수 있는지 알아봐야겠습니다..

 

https://community.letsencrypt.org/t/convert-manual-to-webroot-renewal/66965

저와 비슷한 문제를 겪는 사람이 올린 글입니다.

wildcard 인증서를 쓰는 사람이.. 자동 갱신이 쉽도록 webroot로 다시 받고 싶다고 한 글인데 wild card인증서 때문에 webroot으로 받는게 안됩니다..

 

흠.. wildcard domain을 지우는 방법은 없을까요?

 

 

https://nscworld.com/letsencrypt-%EC%9D%B8%EC%A6%9D%EC%84%9C-%EC%82%AD%EC%A0%9C%EB%B0%A9%EB%B2%95/

 

certbot delete 명령어를 사용하면.. 인증서(certificate) 단위로 삭제할 수 있습니다.

그런데 저는.. 하나의 인증서에서 xxx.com과 *.xxx.com(와일드카드) 도메인을 사용하고 있어.. 와일드 카드의 도메인만 삭제는 안되는 것 같네요..

 

결국 저는.. rm -rf /etc/letsencrypt 폴더를 강제 삭제하고..

처음부터 새로 설치했습니다. ㅎㅎ;;;

 

운영서버의 인증서라 설치 과정이 오래 걸리면 어떡하나 걱정했는데 수분 내에 해결이 가능했습니다.

 

참고

인증서 남은 기간 확인하는 명령어: sudo certbot certificates

aws lightsail let's encrypt 인증서 설치하기

https://swiftcoding.org/lets-encrypt-auto-renew

작성자

Posted by 드리머즈

관련 글

댓글 영역