Let's Encrypt 로 무료 인증서를 발급 받을려고 했더니 "DNS problem: SERVFAIL looking up CAA for ..." 에러 메시지가 뜨면서 더 이상 진행이 안되네요~

직접 네임서버 운영으로 해결했습니다.

# certbot certonly --standalone --agree-tos -m email@address -d www.example.kr
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator standalone, Installer None
Starting new HTTPS connection (1): acme-v02.api.letsencrypt.org
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for www.example.kr
Waiting for verification...
Cleaning up challenges
Failed authorization procedure. www.example.kr (http-01): urn:ietf:params:acme:error:dns :: DNS problem: SERVFAIL looking up CAA for www.ivps.kr

IMPORTANT NOTES:
 - The following errors were reported by the server:

   Domain: www.example.kr
   Type:   None
   Detail: DNS problem: SERVFAIL looking up CAA for www.example.kr

CAA 레코드를 지정하고 난 뒤에 인증서 발급이 되네요~

 

www.example.kr.        CAA 0   issue   "letsencrypt.org"

/var/named/example.kr.zone 파일에 위의 필드를 추가하고 named 재시작 하고 인증서 발급해보세요~

 

블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

LETSENCRYPT SSL 인증서 자동갱신 쉘스크립트



Let's encrypt 무료 SSL 인증서는 유효기간이 90일입니다.


거의 3달 만에 한번씩 갱신을 해주어야 하는 불편함이 있지요~


아래 처럼 스크립트로 만들어서 크론으로 자동갱신하면 편리합니다.



#!/bin/sh


TODAY=`date +%Y%m%d%H`

LOG_FILE="/root/letsencrypt.txt"

KEY_PATH="/etc/letsencrypt/live"

KEY_FILE="cert.pem"

EMAIL="email@example.com"

DOMAINS="

    www.example.com

    "


if [ -e "/usr/bin/letsencrypt" ] ; then

    LETSENCRYPT="/usr/bin/letsencrypt"

else

    LETSENCRYPT="/root/letsencrypt/letsencrypt-auto"

fi


for DOMAIN in $DOMAINS ; do

    CERT_PATH="$KEY_PATH/$DOMAIN/$KEY_FILE"

    if [ -e "$CERT_PATH" ] ; then

        C_DATE=`openssl x509 -in $CERT_PATH -text -noout | grep After | awk -F ' : ' '{print $2}'`

        R_DATE=`date +%Y%m%d%H --date="$C_DATE -1 days"`

        if [ "$TODAY" -ge "$R_DATE" ] ; then

            echo "# $DOMAIN renew date : "`date` >> $LOG_FILE

            /root/bin/web-service.sh stop

            $LETSENCRYPT renew >> $LOG_FILE

            /root/bin/web-service.sh start

        fi

    else

        echo "# $DOMAIN create date : "`date` >> $LOG_FILE

        /root/bin/web-service.sh stop

        $LETSENCRYPT certonly --standalone --agree-tos -m $EMAIL -d $DOMAIN

        /root/bin/web-service.sh start

    fi

done


web-service.sh 스크립트는 자신의 환경에 맞게 직접 만드셔야 합니다.


아파치랑 nginx 를 같이 사용한다면 둘다 서비스를 종료했다가 다시 재시작 해주는 스크립트를 만들면 됩니다.


https://ivps.tistory.com/630 여기를 참고하면 됩니다.


블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

LETSENCRYPT 인증서 만료날짜 알아내는 방법



lentsencrypt 로 발급 받은 인증서는 유효기간이 90일입니다.


그래서 90일 마다 갱신을 해주어야 하는데 만료날짜를 알아내는 방법입니다.


정확하게 알아내는 방법은 아래와 같습니다.


# openssl x509 -in /etc/letsencrypt/live/www.example.com/cert.pem -text -noout | grep After
            Not After : Dec 21 04:33:00 2017 GMT


좀 더 디테일하게 파싱까지 하면


# openssl x509 -in /etc/letsencrypt/live/www.example.com/cert.pem -text -noout | grep After | awk -F ' : ' '{print $2}'

Dec 21 04:33:00 2017 GMT


# AFTERDAY=`openssl x509 -in /etc/letsencrypt/live/www.example.com/cert.pem -text -noout | grep After | awk -F ' : ' '{print $2}'`

# date +%Y%m%d --date="$AFTERDAY"

20171221

쉘스크립트로 만들어서 활용하면 됩니다.


간단하게는


stat /etc/letsencrypt/live/www.example.com/cert.pem | grep Modify


위 명령어로 생성일자 +90 만료일자를 계산하는 방법도 있습니다.



블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

리눅스 letsencrypt 만료 갱신



letsencrypt SSL 인증서는 아쉽게도 90일 지나면 만료가 됩니다.


만료전에 갱신을 하면 좋은데 CRON 으로 letsencrypt-auto renew 명령으로 갱신하려고 했더니 아래 처럼 에러가 나네요~


All renewal attempts failed. The following certs could not be renewed:

  /etc/letsencrypt/live/www.example.com/fullchain.pem (failure)


httpd, nginx 데몬이 실행중 일때는 /var/log/letsencrypt/letsencrypt.log 파일을 보면

"Problem binding to port 443: Could not bind to IPv4 or IPv6.. Skipping" 메시지가 나옵니다.

갱신전에 미리 웹서비스 데몬을 중지한 다음에 갱신하여야 합니다.


Congratulations, all renewals succeeded. The following certs have been renewed:
  /etc/letsencrypt/live/www.example.com/fullchain.pem (success)



갱신시간을 정확하게 90일이 지나는 시분에 맞춰서 크론에 등록해 주면 됩니다.


ls -l /etc/letsencrypt/live 하면 언제 생성이 되었는지 시간을 알 수 있습니다.


크론실행은 매일 실행되게 하고 시간만 맞게 해주면 됩니다.




CentOS 6.x 버전은 letsencrypt-auto renew


CentOS 7.x 버전은 letsencrypt renew 입니다.



'LINUX' 카테고리의 다른 글

CentOS 7.x iscsi 스토리지 생성 및 연결  (0) 2017.09.18
CentOS 7.x PXE 서버 설정  (0) 2017.09.13
CentOS 7.x anonymous upload 설정  (0) 2017.08.22
CentOS 7.x VNCSERVER 설치  (0) 2017.08.17
CentOS 7.x KVM 가상화서버 만들기  (0) 2017.08.17
블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

LETSENCRYPT 인증서 갱신 renew parsefail



인증서가 만료가 다 되어 letsencrypt renew 를 했더니 아래처럼 에러가 나네요~


다른 서버에서 발급 받은 인증서를 옮긴 서버에 복사해서 사용해서 그런거 같기도 하네요. 


Additionally, the following renewal configuration files were invalid:

  /etc/letsencrypt/renewal/www.example.com.conf (parsefail)


아무튼 이런 경우엔 관련 파일을 다 지우고 다시 발급 받으면 되더군요~


# rm -rf /etc/letsencrypt/archive/www.example.com

# rm -rf /etc/letsencrypt/live/www.example.com

# rm -rf /etc/letsencrypt/renewal/www.example.com.conf


파일을 지운 다음에 다시 발급 받아 보세요.


CentOS 6.x 버전은


/root/letsencrypt/letsencrypt-auto certonly --standalone --agree-tos -m email@example.com -d www.example.com


CentOS 7.x 버전은


/usr/bin/letsencrypt certonly --standalone --agree-tos -m email@example.com -d www.example.com


인증서가 발급되었는지 확인해보세요.


블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

CentOS 6.x letsencrypt install



7.x 버전에서는 yum install 로 설치가 됩니다.


그런데 6.x 버전에서는 python 이 2.7 버전대가 아닌 2.6 버전이라서 설치가 안되는 것 같습니다.


아래 처럼 메시지가 뜨면서 진행이 안되네요.


# yum install letsencrypt

...

No package letsencrypt available.

Error: Nothing to do


그래도 구글링해보니 방법은 있더군요.


# yum update


# yum install epel-release


# rpm -ivh https://rhel6.iuscommunity.org/ius-release.rpm


# yum --enablerepo=ius install python27 python27-devel python27-pip python27-setuptools python27-virtualenv


# yum install git


# cd /root


# git clone https://github.com/letsencrypt/letsencrypt


# cd letsencrypt


# ./letsencrypt-auto


7.x 버전에서는 /usr/bin/letsencrypt 파일로 실행되지만


위 처럼 git 로 가져오면 /root/letsencrypt-auto 파일을 실행하면 됩니다.


블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

SSL 인증서 무료로 발급 받는 방법



letsencrypt.org 에서 공인발급되는 인증서입니다.


리눅스에 letsencrypt 를 설치해서 수동으로 발급이 가능합니다.


아쉬운 점이 유효기간이 3개월이고, 멀티도메인으로 발급이 안된다는 점입니다.


그리고 renew 옵션을 사용해서 갱신하면 됩니다.


startssl.com 에서 발급 받다가 포기하고 찾은건데 괜찮네요~



테스트 환경은 CentOS 7.x 에 Apache 입니다.



▶ letsencrypt 설치


# yum install letsencrypt



▶ 인증서 발급


# letsencrypt certonly --standalone -d conoha.ivps.kr


아래 처럼 명령어를 실행하면 이메일과 동의를 묻지 않고 진행이 됩니다.


# letsencrypt certonly --standalone --agree-tos -m 메일주소 -d 도메인명



SSL 인증서 무료로 발급 받는 방법SSL 인증서 무료로 발급 받는 방법


이메일을 입력합니다.



SSL 인증서 무료로 발급 받는 방법SSL 인증서 무료로 발급 받는 방법


동의를 합니다.



SSL 인증서 무료로 발급 받는 방법SSL 인증서 무료로 발급 받는 방법


httpd 데몬을 멈춰야 발급이 되나봅니다.


systemctl stop httpd


다시 발급을 시도하면 아래 화면 처럼 발급이 금방됩니다.



SSL 인증서 무료로 발급 받는 방법SSL 인증서 무료로 발급 받는 방법



▶ 인증서 갱신 방법


# letsencrypt renew



아래에서 아파치에서 인증서 설정 방법에 대해서 알아봅시다.


https://ivps.tistory.com/189


블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,