IT 알쓸신잡

Certbot을 이용한 Let's Encrypt SSL 인증서 발급 본문

Server

Certbot을 이용한 Let's Encrypt SSL 인증서 발급

솦트웰러 2023. 2. 26. 20:55
728x90
반응형

운영중인 서버에 새로운 도메인을 등록하여 httpd.conf와 ssl.conf 설정을 하기 전에 SSL 인증서를 발급받아야 합니다.

 

만약 상용 SSL 인증서를 구매해서 사용하고자 하면,  Sectigo(COMODO) Positive SSL이 제일 가성비가 좋은거 같네요.

Positive SSL 인증서 상세 보기 - HanbiroSSL (comodossl.co.kr)

 

Positive SSL 인증서 상세 보기 - HanbiroSSL

SSL 보안 서버 인증 가장 합리적인 가격의 Sectigo SSL 인증을 통해 귀사의 웹서버에 접속하는 회원들의 개인 정보를 안전하게 보호해 주시기 바랍니다. -->

www.comodossl.co.kr

 

구매 SSL 인증서는 제대로 서비스 할때 적용하기로 하고, 무료로 제일 많이 사용하는 Let's Encrypt SSL 인증서를 발급받는 방법을 알아보도록 합시다.

 

1. Let's Encrypt SSL 특징

인증서 발급 기관, CA(Certificate Authority) 업체 중 하나이며 아래와 같은 특징을 가지고 있습니다. (제일 중요한 무료~)

  • 인증 절차가 단순해 단 한 줄 명령어로 발급 가능
  • 발급 대기 시간 없이 바로 발급
  • Nginx나 아파치와 같은 웹서버에 맞추어 자동 옵션 설정되도록 설치 가능
  • 인증 유효기간은 90일이지만 인증을 자동화 가능

 

2. Certbot 설치

Apache 웹 서버 기준으로 Certbot 과 Certbot Apache 웹서버 플러그인을 설치합니다.

yum install -y certbot python2-certbot-apache

 

3. 인증서 발급

certbot 을 이용한 인증서 발급 시 몇 가지 옵션이 있습니다만 발급 절차가 간소한 standalone 방식을 이용해서 발급을 받도록 합니다.

certbot certonly --standalone -d swmaster.com -d www.swmaster.com

--standalone 옵션 앞에 certonly 옵션은 certbot이 웹서버 구성파일 직접 수정 못하도록 하는 옵션입니다.

--standalone 옵션을 사용하기 위해서는 아래 명령어를 사용하여 Apache 웹서버를 중지하고 사용하여야 합니다.

systemctl stop httpd

 

아래와 같이 문구가 나온다면 발급이 성공입니다.

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/swmaster.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/swmaster.com/privkey.pem
   Your certificate will expire on 2023-05-15. 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

 

4. ssl.conf 파일에 설정 등록

/etc/letsencrypt/live/swmaster.com/ 디렉토리 하위에 인증서, 체인인증서, 키파일을 ssl.conf에 등록해줍니다.

vi /etc/httpd/conf.d/ssl.conf
<VirtualHost _default_:443>
DocumentRoot “/home/swmaster/www”
ServerName swmaster.com:443
ServerAlias www.swmaster.com:443

SSLCertificateFile /etc/letsencrypt/live/swmaster.com/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/swmaster.com/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/swmaster.com/chain.pem
SSLCACertificateFile /etc/letsencrypt/live/swmaster.com/fullchain.pem

</VirtualHost>

 

5. Apache 재시작 및 certbot 갱신
systemctl start httpd

위 명령어로 문제없이 동작한다면 ssl 인증서가 적용된 Apache 웹서버가 동작되었습니다.

 

갱신 기간이 다가올 경우 아래 명령어로 갱신을 할 수 있습니다.

certbot renew

Let's Encrypt에서 발급받은 인증서들 전체를 갱신 기간 체크하여 갱신 기간일 경우 갱신을 진행합니다.

 

설치된 인증서 경로를 변경하지 않았다면 자동으로 업데이트 되서 별도 설정할 필요는 없습니다.

인증서 경로는 /etc/letsencrypt/live/도메인/ 하위에 있습니다.

 

 

728x90
반응형

'Server' 카테고리의 다른 글

리눅스 디스크 용량 확보 방법  (0) 2023.02.06
Comments