Cert scan Azure App Gateway
Revision as of 22:05, 23 January 2024 by Busk (talk | contribs) (Created page with "vim .env ``` set -a AZ_SUBSCRIPTION_ID=mysub-id-blah ``` ``` . .env ``` cert-scan-agws-be-certs.sh ``` #!/bin/bash set -eu if "$#" -ne 1 ; then echo "Usage: $0 <reso...")
vim .env
set -a AZ_SUBSCRIPTION_ID=mysub-id-blah
. .env
cert-scan-agws-be-certs.sh
#!/bin/bash set -eu if [[ "$#" -ne 1 ]]; then echo "Usage: $0 <resource group name>" echo "Example: $0 my-rgrp" exit fi rg=$1 agws=($(az network application-gateway list --resource-group $rg --subscription ${AZ_SUBSCRIPTION_ID} --query "[].name" --output tsv)) outfile="backend-hosts.txt" get_be_targets(){ echo "" > $outfile for agw in "${agws[@]}"; do az network application-gateway show-backend-health --name $agw --resource-group $rg --subscription ${AZ_SUBSCRIPTION_ID} --query 'backendAddressPools[].backendHttpSettingsCollection[].servers[].address' --output tsv >> "${outfile}" done echo "Your hosts are in ${outfile}" } # get_be_targets hosts=$(cat $outfile | sed 's/$textToRemove//g') cert -f json -skip-verify $hosts | jq -r '(. | map(leaf_paths) | unique) as $cols | map (. as $row | ($cols | map(. as $col | $row | getpath($col)))) as $rows | ([($cols | map(. | map(tostring) | join(".")))] + $rows) | map(@csv) | .[]' > ${outfile}.csv echo "Your cert scan results in csv are in ${outfile}.csv"