티스토리 뷰

Let's encrypt는  모질라 재단에서 무료 SSL 인증서를 발급을 해주 는프로젝트 이다.

 

무료로 발급을 하다보니 제약사항이 따른다.

1. 90일 단위로 갱신을 해야 하는 점

2. 1개의 IP 에서 3시간동안 10개의 도메인을 허용

3. 7일 동안 1개의 도메인에서 5개의 도메인레코드 선언을 허용

Ex] domain.com, www.domain.com, blog.domain.com... 하나의 도메인에 서브 도메인이 5개의 도메인레코드만 선언

이 제한은 발급받은 SSL을 취소(revoke)를 하거나 /etc/letsencrypt에 생성된 항목을 삭제 하더라도 도메인수는 반영안됨

 

Let's encrypt 설치

1. 레포지토리 추가 및 필요한 라이브러리 설치 및 깃허브를 통한 Let's encrypt 다운로드

myLinux~]# cd /usr/local
myLinux~]# yum install epel-release
myLinux~]# rpm -ivh https://rhel6.iuscommunity.org/ius-release.rpm
myLinux~]# yum install git python27 python27-devel python27-pip python27-setuptools python27-virtualenv python27-libs
myLinux~]# git clone https://github.com/certbot/certbot

 

Let's encrypt 실행

myLinux~]# cd /usr/local/certbot
myLinux~]# ./certbot-auto certonly

 

Let's encrypt 인증서 발급

myLinux~]# cd /usr/local/certbot
myLinux~]# ./certbot-auto certonly --server https://acme-v01.api.letsencrypt.org/directory \
                   --rsa-key-size 4096 --agree-tos \
                   --email domain@gmail.com \
                   --webroot -w /var/www/html \
                   -d domain.com -d www.domain.com -d blog.domain.com

여기서 4번째줄부터 6번째줄까지는 본인에 맞는 이메일과 웹루트디렉토리 도메인명을 설정해줘야한다.

 

Apache 설정

SSLProtocol            ALL -SSLv2 -SSLv3
SSLCipherSuite         ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!3DES:!MD5:!PSK
SSLHonorCipherOrder    on
 
Listen 443
<VirtualHost *:443>
	DocumentRoot /var/www/html
	ServerName domain.com
	SSLEngine on
	SSLCertificateFile /etc/letsencrypt/live/domain.com/cert.pem
	SSLCertificateKeyFile /etc/letsencrypt/live/domain.com/privkey.pem
	SSLCertificateChainFile /etc/letsencrypt/live/domain.com/chain.pem
	SSLCACertificateFile /etc/letsencrypt/live/domain.com/fullchain.pem
	Header always set Strict-Transport-Security "max-age=15552000"
</VirtualHost>

위와 같이 설정후 https://www.ssllabs.com/ssltest 에서 테스테스를 해보고 Overall Rating가

어떻게 나오는지 보아야 한다. 위 설정은 A+이 나온다.

 

90갱신을 자동 갱신

myLinux~]# vi /etc/cron.daily/letsencrypt_renew.sh

#!/bin/bash
# 실행 조건 1일 1회 작동
## pid 생성 중복실행을 방지 #######################################################
if [[ -s $0.pid ]];then exist_pid=`cat $0.pid`
  if [[ -z `ps -e|grep $exist_pid` ]];then rm -f $0.pid;exec_confirm="Y"
  else exec_confirm="N";echo -e "\e[1;32mShell has already running...\e[0m";fi
else exec_confirm="Y";fi
if [[ $exec_confirm == "Y" ]];then
  echo $$ > $0.pid
###############################################################################################
  cd /usr/local/certbot
## chattr -i /usr/bin/gcc /usr/bin/g++ -> 보안으로 인해 풀어야 하는 경우       ###################
  /usr/local/certbot/certbot-auto renew --quiet
## chmod 700 /usr/bin/gcc /usr/bin/g++;chattr +i /usr/bin/gcc /usr/bin/g++ -> 보안으로 막는다.###
  find /tmp -maxdepth 1 -type d -perm 700 -user root -name 'tmp.*' -exec rm -rf {} \;
###############################################################################################
  rm -f $0.pid
fi
###############################################################################################

:wq

 

인증서에 도메인 추가

myLinux~]# cd /usr/local/letsencrypt
myLinux~]# ./letsencrypt-auto certonly --server https://acme-v01.api.letsencrypt.org/directory \
                       --rsa-key-size 4096 -agree-dev-preview --agree-tos \
                       --webroot -w /free/home/enteroa/html/ \
                       --email domain@gmail.com \
                       -d domain.com -d www.domain.com -d blog.domain.com -d nas.domain.com

nas.domain.com을 추가를 해야 할 경우 기존에 등록이 되어 있는 도메인의 인증서 등록을

기존 도메인명부터 다시 선언하여 도메인을 추가 해주면 된다.

위와 같이 도메인 추가되는 부분을 실행하면 기존 인증서에 도메인을 추가 할지 물어보는데 엔터를 누르면 된다.

 

자세한 가이드는 아래 링크를 참조

https://letsencrypt.readthedocs.io/en/latest/using.html

 

User Guide — Certbot 0.34.0.dev0 documentation

Certbot uses a number of different commands (also referred to as “subcommands”) to request specific actions such as obtaining, renewing, or revoking certificates. The most important and commonly-used commands will be discussed throughout this document; an

letsencrypt.readthedocs.io

 

 

출처 블로그

https://www.enteroa.com/2016/03/12/lets-encrypt-%EC%84%A4%EC%B9%98-%EB%B0%8F-%EC%9A%B4%EC%9A%A9centos/

'System > Linux' 카테고리의 다른 글

SSH 접속시 에러  (0) 2022.01.29
CentOS Stream으로 인한 대처 방안  (0) 2021.04.21
페도라 Subversion설치  (0) 2008.07.26
[Apache] mod_rewrite 설치  (0) 2008.07.26
스팸중계  (0) 2008.07.26
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함