์ž์œ ๊ฒŒ์‹œํŒ

  • ์‹œ๋†€๋กœ์ง€ ๋‚˜์Šค Cloudflare DNS Let's Encrypt WildCard SSL ์ ์šฉ

    ํŽ˜์ด์ง€ ์ •๋ณด

    profile_image
    ์ž‘์„ฑ์ž์ฒœ์‚ฌ ์กฐํšŒ 9,694ํšŒ ์ž‘์„ฑ์ผ 2021-08-30 21:26:31 ๋Œ“๊ธ€ 0

    ๋ณธ๋ฌธ

    sudo -i

    cd ~

    wget https://github.com/Neilpang/acme.sh/archive/master.tar.gz

    tar xvf master.tar.gz

    cd acme.sh-master

    ย 

    ./acme.sh --install --nocron --home /usr/local/share/acme.sh --accountemail "์ด๋ฉ”์ผ" --server letsencrypt

    ย 

    cd /usr/local/share/acme.sh/

    ย 

    export CF_Key="๊ธ€๋กœ๋ฒŒ API ํ‚ค"

    export CF_Email="์ด๋ฉ”์ผ"

    export CERT_DNS="dns_cf"

    ย 

    ./acme.sh --issue -d *.๋„๋ฉ”์ธ -d ๋„๋ฉ”์ธ --dns $CERT_DNS --cert-file /usr/syno/etc/certificate/system/default/cert.pem --key-file /usr/syno/etc/certificate/system/default/privkey.pem --fullchain-file /usr/syno/etc/certificate/system/default/fullchain.pem --reloadcmd "/usr/syno/sbin/synoservicectl --reload nginx" --dnssleep 30 --force --server letsencrypt

    ย 

    export CERT_FOLDER="$(find /usr/syno/etc/certificate/_archive/ -maxdepth 1 -mindepth 1 -type d)"

    export CERT_DNS="dns_cf"

    ย 

    ./acme.sh --issue -d *.๋„๋ฉ”์ธ -d ๋„๋ฉ”์ธ --dns "$CERT_DNS" --cert-file "$CERT_FOLDER/cert.pem" --key-file "$CERT_FOLDER/privkey.pem" --fullchain-file "$CERT_FOLDER/fullchain.pem" --capath "$CERT_FOLDER/chain.pem" --reloadcmd "/usr/syno/sbin/synoservicectl --reload nginx" --dnssleep 30 --force --server letsencrypt

    ย 

    ์ œ์–ดํŒ > ์ž‘์—… ์Šค์ผ€์ค„๋Ÿฌ > ์˜ˆ์•ฝ๋œ ์ž‘์—… > ์‚ฌ์šฉ์ž ์ •์˜ ์Šคํฌ๋ฆฝํŠธ

    ย 

    # Note: The $CERT_FOLDER must be hardcoded here since the running environment is unknown. Don't blindly copy&paste!
    # if you used the normal method the certificate will be installed in the system/default directory CERTDIR="system/default"
    # if you used the alternative method it is copied to an unknown path, change the following example to the output of the creation process and uncomment.
    #CERTDIR="_archive/AsDFgH"

    # do not change anything beyond this line!
    CERTROOTDIR="/usr/syno/etc/certificate"
    PACKAGECERTROOTDIR="/usr/local/etc/certificate"
    FULLCERTDIR="$CERTROOTDIR/$CERTDIR"

    # renew certificates, this used to be explained as a custom cronjob but works just as well within this script according to the output of the task.
    /usr/local/share/acme.sh/acme.sh --cron --home /usr/local/share/acme.sh/

    # find all subdirectories containing cert.pem files
    PEMFILES=$(find $CERTROOTDIR -name cert.pem)
    if [ ! -z "$PEMFILES" ]; then
    ย  ย  ย  ย  for DIR in $PEMFILES; do
    ย  ย  ย  ย  ย  ย  ย  ย  # replace the certificates, but never the ones in the _archive folders as those are all the unique
    ย  ย  ย  ย  ย  ย  ย  ย  # certificates on the system.
    ย  ย  ย  ย  ย  ย  ย  ย  if [[ $DIR != *"/_archive/"* ]]; then
    ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  rsync -avh "$FULLCERTDIR/" "$(dirname $DIR)/"
    ย  ย  ย  ย  ย  ย  ย  ย  fi
    ย  ย  ย  ย  done
    fi

    # reload
    /usr/syno/sbin/synoservicectl --reload nginx

    # update and restart all installed packages
    PEMFILES=$(find $PACKAGECERTROOTDIR -name cert.pem)
    if [ ! -z "$PEMFILES" ]; then
    ย  ย  ย  ย  for DIR in $PEMFILES; do
    ย  ย  ย  ย  ย  ย  ย  ย  #active directory has it's own certificate so we do not update that package
    ย  ย  ย  ย  ย  ย  ย  ย  if [[ $DIR != *"/ActiveDirectoryServer/"* ]]; then
    ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  rsync -avh "$FULLCERTDIR/" "$(dirname $DIR)/"
    ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  /usr/syno/bin/synopkg restart $(echo $DIR | awk -F/ '{print $6}')
    ย  ย  ย  ย  ย  ย  ย  ย  fi
    ย  ย  ย  ย  done
    fi

    ๋Œ“๊ธ€๋ชฉ๋ก

    ๋“ฑ๋ก๋œ ๋Œ“๊ธ€์ด ์—†์Šต๋‹ˆ๋‹ค.