|
|
|
@ -32,9 +32,10 @@ parse_response() { |
|
|
|
|
|
|
|
# Function to deploy base64-encoded certificate to firewall |
|
|
|
deployer() { |
|
|
|
cert_base64=$(cat "$_cfullchain" | _base64 | tr -d '\n') |
|
|
|
key_base64=$(cat "$_ckey" | _base64 | tr -d '\n') |
|
|
|
payload=$(cat <<EOF |
|
|
|
cert_base64=$(_base64 <"$_cfullchain" | tr -d '\n') |
|
|
|
key_base64=$(_base64 <"$_ckey" | tr -d '\n') |
|
|
|
payload=$( |
|
|
|
cat <<EOF |
|
|
|
{ |
|
|
|
"type": "regular", |
|
|
|
"scope": "global", |
|
|
|
@ -43,7 +44,7 @@ deployer() { |
|
|
|
"file_content": "$cert_base64" |
|
|
|
} |
|
|
|
EOF |
|
|
|
) |
|
|
|
) |
|
|
|
url="https://${FGT_HOST}:${FGT_PORT}/api/v2/monitor/vpn-certificate/local/import" |
|
|
|
_debug "Uploading certificate via URL: $url" |
|
|
|
_H1="Authorization: Bearer $FGT_TOKEN" |
|
|
|
@ -54,15 +55,16 @@ EOF |
|
|
|
|
|
|
|
# Function to upload CA certificate to firewall (FortiGate doesn't automatically extract CA from fullchain) |
|
|
|
upload_ca_cert() { |
|
|
|
ca_base64=$(cat "$_cca" | _base64 | tr -d '\n') |
|
|
|
payload=$(cat <<EOF |
|
|
|
ca_base64=$(_base64 <"$_cca" | tr -d '\n') |
|
|
|
payload=$( |
|
|
|
cat <<EOF |
|
|
|
{ |
|
|
|
"import_method": "file", |
|
|
|
"scope": "global", |
|
|
|
"file_content": "$ca_base64" |
|
|
|
} |
|
|
|
EOF |
|
|
|
) |
|
|
|
) |
|
|
|
url="https://${FGT_HOST}:${FGT_PORT}/api/v2/monitor/vpn-certificate/ca/import" |
|
|
|
_debug "Uploading CA certificate via URL: $url" |
|
|
|
_H1="Authorization: Bearer $FGT_TOKEN" |
|
|
|
@ -78,12 +80,13 @@ EOF |
|
|
|
|
|
|
|
# Function to activate the new certificate |
|
|
|
set_active_web_cert() { |
|
|
|
payload=$(cat <<EOF |
|
|
|
payload=$( |
|
|
|
cat <<EOF |
|
|
|
{ |
|
|
|
"admin-server-cert": "$_cdomain" |
|
|
|
} |
|
|
|
EOF |
|
|
|
) |
|
|
|
) |
|
|
|
url="https://${FGT_HOST}:${FGT_PORT}/api/v2/cmdb/system/global" |
|
|
|
_debug "Setting GUI certificate..." |
|
|
|
_H1="Authorization: Bearer $FGT_TOKEN" |
|
|
|
|