Let’s Encrypt는 자동화된 무료 공인 인증 기관(CA)입니다(Let’s Encrypt is a free, automated, and open Certificate Authority).
기존 Let’s Encrypt 사용자 여러분들에게 특별한 소식입니다. 무려 Wildcard Certificate1를 지원한다는 소식( 원문보기)이죠!
ACMEv2가 Production으로 공식 지원된지는 지난 3월 13일부터 벌써 한달이 다 되어가는데, 아직 한국에는 관련한 소식을 접할 수가 없네요. Let’s Encrypt 공식 포럼에서 관련한 내용을 접할 수 있었습니다.
1. 준비물
그럼 본론으로 들어가서 준비물을 알아보도록 하겠습니다.
Certbot
( >= 0.22.0)- 갱신할 도메인 주소 (e.g.
blending.kr
) - 도메인 공급업체 또는 DNS 관리업체 로그인 계정 (e.g. 가비아, dnsever, 또는 개인 DNS 서버
bind9
등)
여기서는 blending.kr, *.blending.kr
주소의 와일드카드 도메인을 개인 도메인 서버 bind9
를 이용해 발급받는 것을 목표로 시작합니다.
개인 도에인 공급업체에서 해당 내용을 변경하기 위해서는, 각 도메인 관리자 사이트에서 아래와 동일하게 DNS TXT 레코드를 변경하시면 됩니다.
2. 구성요소 확인
먼저 설치된 Certbot
이 최신 버전인지 확인합니다.
> certbot --version
certbot 0.22.2
버전이 0.22.0 이상이라면 다음으로 넘어가도 좋습니다.
3. DNS-01 challenge 준비
certbot
을 이용하여 다음과 같은 명령어를 관리자 권한(root
)으로 입력합니다.
> certbot certonly \
--manual \
--preferred-challenges dns-01 \
--server https://acme-v02.api.letsencrypt.org/directory \
-d *.blending.kr \
-d blending.kr
해당 명령어는 dns-01 challenge를 이용하여 수동 발급 요청을 ACMEv2 서버로 전송합니다. 아래와 같이 “IP 로그를 활성화할 것이냐”라고 물으면 Y를 입력하고 넘어갑니다.
Performing the following challenges:
dns-01 challenge for blending.kr
dns-01 challenge for blending.kr
-------------------------------------------------------------------------------
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:
다음으로, 생성된 DNS TXT 레코드를 메모장 같은 곳에 임시로 적어둡니다. 다음 단계에서 TXT 레코드에 추가할 내용입니다.
-------------------------------------------------------------------------------
Please deploy a DNS TXT record under the name
_acme-challenge.blending.kr with the following value:
<TXT 값 1>
Before continuing, verify the record is deployed.
-------------------------------------------------------------------------------
Press Enter to Continue
-------------------------------------------------------------------------------
Please deploy a DNS TXT record under the name
_acme-challenge.blending.kr with the following value:
<TXT 값 2>
Before continuing, verify the record is deployed.
-------------------------------------------------------------------------------
Press Enter to Continue
위의 경우 Press Enter to Continue
가 한번 뜨면 Enter를 눌러주셔아만 두번째 TXT값이 뜹니다.
두 번 이상 계속하면 DNS TXT값 없이 Challenge를 진행하게 되므로 오류가 발생하므로, 한번만 눌러서 위와 같이 만들어 주셔야 합니다!
4. DNS 레코드 수정
여기서는 bind9
의 설정 파일을 수정해 DNS TXT 레코드를 추가해 보도록 하겠습니다. 파일 위치는 시스템 설정마다 다를 수 있으므로 참고하시기 바랍니다.
> sudo vi /etc/bind/zones/db.<도메인명>

위와 같이 <TXT 값 1>
과 <TXT 값 2>
를 넣어주고, serial 부분을 업데이트(e.g. 2018040701) 해준 뒤, [ESC], :wq!
를 입력하여 빠져나와 다음과 같이 DNS 설정을 적용시켜줍니다.
> sudo service bind9 restart
5. DNS TXT 레코드 적용여부 확인
직접 확인하는 방법은 dig
명령어를 이용해 가능합니다.
> dig +noall +answer _acme-challenge.blending.kr txt
_acme-challenge.blending.kr. 604800 IN TXT "<TXT 값 1>"
_acme-challenge.blending.kr. 604800 IN TXT "<TXT 값 2>"
위와 같이 TXT값이 나타났다면 성공! 그렇지 않은 경우 업데이트가 안되었다는 것이니 4번의 설정이 잘 저장되고, 다시 로드되었는지 확인해볼 필요가 있겠네요.
6. 적용된 DNS TXT 레코드로 Challenge 마무리
아까의 터미널 창으로 돌아가, Enter만 눌러주면 모른 동작이 완료됩니다.
Waiting for verification...
Cleaning up challenges
IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/blending.kr/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/blending.kr/privkey.pem
Your cert will expire on 2018-07-06. 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
이제 SSL 인증서가 모두 Wildcard로 작동할 것입니다. 기존처럼 길게 -d <도메인명> -d <도메인명2> -d <도메인명3> ...
이런식으로 진행하지 않아도 되겠군요.
7. 아쉬운 마무리.
이렇다할 인증 과정이 필요한 이유는 아직까지는 ACMEv2
인증이 DNS-01
챌린지밖에 지원하지 않기 때문입니다. 다른 인증밥업을 지원했더라면 쉽게 할 수도 있겠네요.
그런데, 무엇보다도
certbot renew
가 안됩니다. 뭐든 수동으로 해야합니다.
아쉽게도 이런 과정을 자동화할 스크립트가 필요하겠네요. 직접 만들어볼까 하는데 얼마나 시간이 걸릴 지는 모르겠네요. 하하.
긴글 따라오시느라 수고하셨습니다. 다음에는 아무래도 이러한 과정을 쉽게 자동화할 수 있는 스크립트를 구상해올께요.
- Wildcard Certificate(와일드카드 인증서)란 기존
home.domain.kr, wiki.domain.kr
등 각 subdomain(home, wiki)에 한정적으로 1개씩 가능했던 것이*.blending.kr
처럼 모든 서브도메인에 발급받는 것이 가능한 SSL 인증서입니다. ↩