메인 항목으로

"acme.sh"를 통한 SSL 인증서 발급

먼저 root 권한으로 변경 합니다.

#

sudo -i

root 디렉토리로 이동합니다.

#

cd ~

"acme.sh" 파일을 다운로드 합니다.

#

wget https://github.com/acmesh-official/acme.sh/archive/master.tar.gz

다운로드 받은 파일의 압축을 해제해 줍니다.

#

tar xvf master.tar.gz

압축해제된 디렉토리로 이동합니다.

#

cd acme.sh-master/

"acme.sh"를 실행하여 설치를 진행합니다.

$

./acme.sh --install --nocron --home /usr/local/share/acme.sh --accountemail "이메일주소"

아래 명령을 추가 실행해 줍니다.

#

source ~/.profile

사용하는 Cloudflare의 정보를 export 해줍니다. (아래 정보는 Cloudflare의 API에서 확인 가능 합니다.)

#

export CF_Email="Cloudflare 이메일"
# export CF_Token="Cloudflare API Token 값
# export CF_Account_ID="계정ID"
#ID" export CF_Zone_ID="영역ID"

ID"

인증서를 생성해 줍니다.

#

cd /usr/local/share/acme.sh 
# export CERT_DNS="dns_cf"

아래의 도메인 입력은 "aaa.com"과 같은 A 레코드 주소와 "*.aaa.com" 같은 와일드카드를 같이 넣어주셔야 합니다.

#

./acme.sh --issue --home . -d '도메인' -d '*.도메인' --dns "$CERT_DNS"

아래와 같은 메시지가 출력되어야 정상 입니다.

[Mon May 1 18:58:10 KST 2023] Cert success.
-----BEGIN CERTIFICATE-----
*********
-----END CERTIFICATE-----
[Mon May 1 18:58:10 KST 2023] Your cert is in: ./도메인_ecc/도메인cer
[Mon May 1 18:58:10 KST 2023] Your cert key is in: ./도메인_ecc/도메인.key
[Mon May 1 18:58:10 KST 2023] The intermediate CA cert is in: ./도메인_ecc/ca.cer
[Mon May 1 18:58:10 KST 2023] And the full chain certs is there: ./도메인_ecc/fullchain.cer

만일 실패 시 아래와 같이 다시 진행 합니다.

./acme.sh --register-account -m 이메일주소 --issue --home . -d '도메인' -d '*.도메인' --dns "$CERT_DNS"

이제 시놀로지 인증서를 신규 발급받은 인증서로 교체 합니다. 주의점은 모든 2단계 인증을 꺼주셔야 합니다,

#

cd /usr/local/share/acme.sh
# export SYNO_Username='시놀로지 로그인 ID'
#ID' export SYNO_Password='*시놀로지 로그인 비번'
# export SYNO_Scheme="http"
# export SYNO_Port="5000"
# export SYNO_Certificate=""
# ./acme.sh --deploy --home . -d '도메인' -d '*.도메인' --deploy-hook synology_dsm

만일 2단계 인증을 사용중이시라면 Cookie를 통해 Device ID를 알아내어 아래 문구를 추가해 주셔야 합니다.

With OTP (2-Factor-Authentication)
Use your browser to sign in with the admin account you want to use. When entering the OTP code, check the "Save this device" checkbox and continue. Get the device ID from the cookie did (Left click on the lock to the left side of the URL -> Cookies and Copy the content of the did cookie). Set the environment variable to the cookie value:

#

export SYNO_DID="DID값"

주기적인 인증서의 자동 갱신은 시놀로지의 스케줄러를 통해 아래 스크립트를 명령해 주시면 됩니다.

/usr/local/share/acme.sh/acme.sh --cron --home /usr/local/share/acme.sh/