인생에 뜻을 세우는데 있어 늦은 때라곤 없다

WEB/Server

Centos 7 Linux 상에서 Nginx 웹서버 기준으로 Let’s Encrypt 인증서 발급방법

projin 2019. 3. 7. 22:57

Centos 7 Linux 상에서 Nginx 웹서버 기준으로 Let’s Encrypt 인증서 발급방법을 작성 할려고 합니다. 


Let’s Encrypt 인증서 발급하기 전에 OpenSSL을 먼저 설치를 하셔야 합니다.




1. certbot 설치

Certbot은 Let’s Encrypt 인증서를 자동으로 발급 및 갱신을 해주는 봇 프로그램입니다.


[root@localhost tmp]# yum -y install certbot



2. certbot 버전 확인

일반적인 인증서의 경우 각 도메인마다 인증서를 적용해야 합니다. 서브도메인을 적용할 경우에는, 각 서브도메인 마다 설정해야 하는 불편함이 있습니다.

이런 단점을 해결하기 위해 certbot의 버전이 0.22이상 부터 Wildcard domain.com(*.domain.com) 발급이 가능합니다.


[root@localhost tmp]# certbot --version

certbot 0.31.0



3. Let’s Encrypt Wildcard 인증서 발급 명령어와 옵션 입력


#[root@localhost tmp]# certbot certonly \

--manual \

--preferred-challenges dns-01 \

--server https://acme-v02.api.letsencrypt.org/directory \

-d domain.com \

-d *.domain.com


4. 인증서에 대한 알림을 받을 이메일을 입력합니다.


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):



5. 이용약관 동의


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

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: 



6. IP 로그 활성화


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

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: 




7. DNS TXT 레코드 등록


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

Please deploy a DNS TXT record under the name

_acme-challenge.domain.com with the following value:


eS4DW7cq9iMfAaWFIW1RFHjsqTRfJSg3GZGD1uakLjM


Before continuing, verify the record is deployed.

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

Press Enter to Continue


도메인이 두 개이기 때문에 한 번 엔터를 누르면 TXT 값이 한 개 더 나옵니다.

네임서버 설정에서 TXT 값을 두 개 넣어야 합니다.


네임서버를 직접 운영할 경우 DNS 레코드 값을 수정하면 되며 가비아 등에서 운영한다면 도메인을 등록한 곳에서 처리를 하면 됩니다.



_acme-challenge IN      TXT     "cmh4TwAsUEzDPzZ_doWN73OXrDYdk-606RYuVqpu8bQ"

_acme-challenge IN      TXT     "rISITqk2xHrOStSlkeZ8uqBT9Ex6VksreHiY1rez8o4"



8. DNS TXT 레코드 등록되었는지 확인(다른 터미널을 열어서 확인)


[root@localhost tmp]# nslookup -type=txt _acme-challenge.domain.com

또는


[root@localhost tmp]# dig +short -t txt _acme-challenge.domain.com


해당 명령어로 TXT 값이 제대로 설정되었는지 확인할 수 있습니다.

등록한 값이 전부 나오는지 확인합니다.

도메인 TTL에 따라 적용되는 시간이 다르게 걸릴 수 있습니다.



9. 정상적으로 TXT 레코드가 등록 되면 아래와 같이 나옵니다.


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

Waiting for verification...

Resetting dropped connection: acme-v02.api.letsencrypt.org

Cleaning up challenges

Resetting dropped connection: acme-v02.api.letsencrypt.org


IMPORTANT NOTES:

 - Congratulations! Your certificate and chain have been saved at:

   /etc/letsencrypt/live/domain.com/fullchain.pem

   Your key file has been saved at:

   /etc/letsencrypt/live/domain.com/privkey.pem

   Your cert will expire on 2019-06-05. 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



10. 인증서 확인


[root@localhost letsencrypt]# ls /etc/letsencrypt/live/domain.com

cert.pem  chain.pem  fullchain.pem  privkey.pem  README



이상으로 Let’s Encrypt Wildcard 인증서 발급이 완료가 되었습니다. 이 인증서의 유효기간이 3개월이므로 3개월이 지나기 전에 재 발급을 받으면 됩니다.

LIST