MENU

CF托管域名SSL签发

April 29, 2022 • linux相关

cf托管的域名ssl一键申请

#!/bin/bash -i
#getssl.sh

DOMAIN=
ALL_DOMAIN=
CFKEY=
CFEMAIL=

# 查看alias扩展是否启用
shopt expand_aliases
# 启用alias扩展
shopt -s expand_aliases
alias acme.sh="~/.acme.sh/acme.sh"

showhelp() {
    echo "Usage: 
    ./getssl.sh [example.com] [[email protected]] [8e53269881db6a7bb78389a5606801c1d287a798]
    "
}

install_acmesh() {
    curl https://get.acme.sh | sh
}

reg_acmesh() {
    acme.sh --register-account -m $CFEMAIL
    export CF_Key="$CFKEY"
    export CF_Email="$CFEMAIL"
}

update_ssl() {
    echo "new ssl cert for the domain:"
    echo ${DOMAIN}
    echo ${ALL_DOMAIN}
    acme.sh --issue --dns dns_cf -d "${DOMAIN}" -d "${ALL_DOMAIN}"
}

process_args() {
    DOMAIN=$1
    ALL_DOMAIN="*.${DOMAIN}"
    CFKEY=$3
    CFEMAIL=$2
    echo "
    DOMAIN=$1
    ALL_DOMAIN='*.${DOMAIN}'
    CFKEY=$3
    CFEMAIL=$2
    "
}

start() {
    cd ~
    install_acmesh
    reg_acmesh
    update_ssl
}

main() {
    if [ $# != 3 ]; then
        showhelp && return
    fi
    process_args [email protected]
    start
}

main [email protected]

使用在线版

curl -s http://ipm.sh/getssl.sh | bash -s abc.com [email protected] 8e53269881db6a7bb78389a5606801c1d287a798