sitelink1 | https://lynlab.co.kr/blog/72 |
---|---|
sitelink2 | https://ilcm96.me/2020-03-16-let-encrypt-wildcard |
sitelink3 | https://github.com/certbot-docker/certbot-docker |
sitelink4 | https://certbot.eff.org/instructions?ws=other&os=windows |
extra_vars5 | |
extra_vars6 |
인증서 발급받기
Certbot에서는 공식적으로 certbot/certbot docker 이미지를 지원하고 있습니다.
Python 기반의 베이스 이미지에, 필요한 각종 라이브러리가 설치되어있으므로 여러분의 서버나 컴퓨터에는 아무것도 설치를 할 필요가 없습니다.
인증서를 발급 받는 커맨드는 다음과 같습니다.
docker run -it --rm --name certbot \
-v '/etc/letsencrypt:/etc/letsencrypt' \
-v '/var/lib/letsencrypt:/var/lib/letsencrypt' \
certbot/certbot certonly -d '*.yourdomain.com' --manual --preferred-challenges dns --server https://acme-v02.api.letsencrypt.org/directory
우선 docker run의 옵션을 살펴봅시다.
-it
: interactive + tty. 요약하자면 터미널을 통해 컨테이너와 상호작용하겠다는 플래그입니다.
Certbot은 발급 과정 중에 커맨드라인을 통해 유저가 입력해야하는 정보들이 있으므로 반드시 필요합니다.--rm
: 작업을 종료하고 컨테이너가 내려가면 자동으로 그 컨테이너를 삭제합니다.-v '...'
: 인증서가 저장될 경로를 볼륨으로 장착합니다.
호스트의 경로는 꼭 위와 같을 필요는 없지만, 많은 자동화 스크립트들이 위 경로에 인증서가 존재한다는 전제로 작동하므로 유지하는게 좋습니다.
다음은 certbot 명령어의 옵션을 살펴봅시다.
-d '*.yourdomain.com'
: 인증서를 발급받을 도메인입니다. 여기서는 와일드카드 인증서를 예시로 들었지만, 도메인 인증서 또한 동일한 방식으로 발급이 가능합니다.--manual --preferred-challenges dns
: 위에서 언급했던 두 가지 방식 중, DNS를 통해 도메인을 인증하겠다는 플래그입니다.--server https://~~~
: 발급을 요청할 let's encrypt 서버 주소입니다. 참고로 와일드카드 인증서는 v02 서버에서만 발급이 가능합니다.
발급 과정은 다음과 같습니다.
우선 위의 커맨드로 발급을 시작합니다. (yourdomain.com 부분을 여러분의 도메인으로 바꿔야한다는 점에 유의하세요!)
>>> docker run ......
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator manual, Installer None
Enter email address (used for urgent renewal and security notices) (Enter 'c' to cancel):
이메일 주소를 입력합니다. 여기서 입력한 주소로 인증서 갱신 및 보안 관련 이메일이 전송됩니다.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel:
A를 눌러 약관에 동의합니다.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o:
EFF 재단에 이메일 주소를 공유함에 동의/거절합니다.
Obtaining a new certificate
Performing the following challenges:
dns-01 challenge for yourdomain.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NOTE: The IP of this machine will be publicly logged as having requested this
certificate. If you're running certbot in manual mode on a machine that is not
your server, please ensure you're okay with that.
Are you OK with your IP being logged?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o:
인증서 발급을 시도한 머신의 IP 주소가 공개적으로 기록될 수 있음을 유의하라는 문구입니다.
만약 IP 주소가 공개되는게 꺼려지신다면 발급을 중단하세요.
대부분의 경우에는 머신의 IP 주소가 곧 DNS상의 A 레코드 주소이기 때문에 문제가 없을 것입니다.
여기서 Y를 누르면 DNS 레코드로 등록할 토큰이 발급됩니다.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please deploy a DNS TXT record under the name
_acme-challenge.yourdomain.com with the following value:
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
Before continuing, verify the record is deployed.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Press Enter to Continue
AAAA...
에 해당하는 위치에 발급된 토큰을 _acme-challenge.yourdomain.com
도메인의 TXT 레코드로 등록해줍니다.
DNSEver와 같은 외부의 도메인 네임 서비스를 이용하고 있다면 해당 서비스 관리화면에 TXT 레코드 등록 메뉴가 있다
docker run에서 입력했던 도메인이 본인 소유인지 확인하는 단계이다.
네임서버를 관리하는 곳에 가서 AAAA... 토큰을 _acme-challenge.ilcm96.me TXT 레코드로 추가하면 된다.
TTL 이상의 시간이 지나고 Enter를 누르면 똑같은 메세지가 토큰만 바뀌어서 나오는데 위에서 입력한 레코드를 지우지 말고 바뀐 토큰을 넣어서 레코드를 추가하면 된다.
도메인 전파에는 다소 시간이 소요되므로, dig 등의 커맨드를 통해 도메인이 잘 전파되었는지 확인한 후 엔터를 눌러야합니다.
아직 전파가 안된 경우에는 발급 절차를 다시 수행해야하고, 재시도 횟수에는 제약이 있으므로 전파 시간을 여유롭게 잡는게 좋습니다.
마지막으로 엔터를 누르면,
Waiting for verification...
Cleaning up challenges
IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/yourdomain.com/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/yourdomain.com/privkey.pem
Your cert will expire on 2019-04-12. To obtain a new or tweaked
version of this certificate in the future, simply run certbot
again. To non-interactively renew *all* of your certificates, run
"certbot renew"
- If you like Certbot, please consider supporting our work by:
Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
Donating to EFF: https://eff.org/donate-le
인증서 발급이 완료되었습니다!
인증서는 자신이 /etc/letsencrypt에 마운트한 폴더 아래에 live나 archive 폴더에 있으므로 자신의 서버에 적용하면 된다.
인증서 갱신
발급된 인증서는 단 3개월간 이용이 가능합니다. 이렇게 기간이 짧은 이유는
- 인증서 갱신의 자동화를 권장하고
- 만약의 사태에 인증서가 무력화되더라도 영향 기간을 3개월 이하로 줄일 수 있기 때문입니다.
이러한 취지에 맞게 인증서 갱신을 crontab 등을 통해 자동화 할 것을 추천드립니다.
Certbot을 통해 발급한 인증서는 마찬가지로 certbot 커맨드를 통해 갱신할 수 있습니다.
>>> docker run -it --rm --name certbot \
-v '/etc/letsencrypt:/etc/letsencrypt' \
-v '/var/lib/letsencrypt:/var/lib/letsencrypt' \
certbot/certbot renew --manual --preferred-challenges dns --server https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing /etc/letsencrypt/renewal/yourdomain.com.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cert not yet due for renewal
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
The following certs are not due for renewal yet:
/etc/letsencrypt/live/yourdomain.com/fullchain.pem expires on 2019-04-12 (skipped)
No renewals were attempted.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
발급할 때 사용했던 커맨드의 도메인 부분을 renew
로만 변경해주면 됩니다.
방금 발급한 인증서는 아직 갱신이 가능한 날짜가 되지 않았다고 뜨네요.