본문 바로가기
linux

Certbot을 이용한 인증서 갱신하기

by codingcampus 2024. 10. 10.
반응형
SMALL

이번 튜토리얼에서는 Certbot을 이용해 인증서를 갱신하는 방법에 대해 알아봅니다. 서버를  https 로 주소를 변화하고 사용 할 때  Let's Encrypt로 인증서를 발급받고 사용을 하고 있습니다. 

Let's Encrypt로 발급받은 인증서의 만료기간이 거의 다 되었다는 메일이 왔을때. 인증서 업데이트를 해줘야 합니다. 

 

  갱신하는 방법은 매우 간단합니다. 먼저 다음 명령어를 통해 인증서 갱신을 시도해 봅니다.

 

 

sudo certbot renew --dry-run

 

 

아무 에러가 없이 다음과 같이 성공했다면 --dry-run 옵션을 빼고 인증서 갱신을 하면 됩니다. 

 

codingcampus@codingcampus:~/coding_campus_flask_app$ sudo certbot renew --dry-run
Saving debug log to /var/log/letsencrypt/letsencrypt.log

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing /etc/letsencrypt/renewal/xxxxxxxxxxxxx.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Simulating renewal of an existing certificate for xxxxxxxxxxxxx and 5 more domains

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations, all simulated renewals succeeded:
 /etc/letsencrypt/live/xxxxxxxxxxxxx/fullchain.pem (success)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

 

 

--dry-run 옵션을 주고 실행하면 실제로 갱신을 진행하는 것이 아닌 갱신을 한번 시도해 에러가 발생할지 아닐지를 미리 알아볼 수 있습니다.

 

이제 정상적으로 성공했습니다. 테스트가 성공했으니 --dry-run 옵션을 빼고 진짜 갱신을 수행해 줍니다

 

sudo certbot renew

 

Congratulations, all simulated renewals succeeded: The following certs have been renewed:

 /etc/letsencrypt/live/xxxxxxxxxxxxx/fullchain.pem (success)
 /etc/letsencrypt/live/xxxxxxxxxxxxx/fullchain.pem (success)
 

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

 

 

이제 인증서 갱신을 끝마쳤으니 웹서버를 재실행하기 전 인증서들이 제대로 갱신되었나 확인해 보도록 하겠습니다. 다음 명령어를 수행해 인증서 정보를 확인합니다

 

sudo certbot certificates

 

모든 인증서가 정상적으로 갱신이 된 것을 확인할 수 있습니다.

 

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Found the following certs:
 Certificate Name: xxxxxxxxxxxxx
   Serial Number: 462b9371a499d4a4d5a22c9f8ad0c99c87c
   Key Type: RSA
   Domains: xxxxxxxxxxxxx
   Expiry Date: 2024-02-22 21:08:10+00:00 (VALID: 68 days)
   Certificate Path: /etc/letsencrypt/live/xxxxxxxxxxxxx/fullchain.pem
   Private Key Path: /etc/letsencrypt/live/xxxxxxxxxxxxx/privkey.pem
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

반응형
LIST