Last active
March 23, 2025 17:41
-
-
Save selivan/9c1213cbd123f5aec62c9310c20ebf1a to your computer and use it in GitHub Desktop.
Script to disable TLS ECH(Encrypted Client Hello) on all zones for a Cloudflare account
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
ACCOUNT_EMAIL="$1" | |
GLOBAL_API_KEY="$2" | |
OPTION="${3:-ech}" | |
VALUE="${4:-off}" | |
if [ -z "${ACCOUNT_EMAIL}" ] || [ -z "${GLOBAL_API_KEY}" ]; then | |
echo "Usage: $0 CLOUDFLARE_ACCOUNT_EMAIL CLOUDFLARE_GLOBAL_API_KEY [OPTION] [VALUE]" | |
echo "Set specified setting for all zones for given account" | |
echo "By default disable TLS ECH, that can not be done from web UI for free accounts" | |
echo "To disable TLS 1.3 sue this option: tls_1_3 off" | |
echo | |
echo "Docs: https://developers.cloudflare.com/api/operations/zone-settings-get-all-zone-settings" | |
echo "Get all available zone settings: GET https://api.cloudflare.com/client/v4/zones/ID_ZONE/settings" | |
exit 1 | |
fi | |
type curl && type jq || exit 1 | |
curl -s -X GET "https://api.cloudflare.com/client/v4/zones" \ | |
-H "X-Auth-Email: ${ACCOUNT_EMAIL}" \ | |
-H "X-Auth-Key: ${GLOBAL_API_KEY}" \ | |
| jq '.result' | jq '.[]' | jq -c '[.id,.name]' \ | |
| while read -r i; do | |
ID_ZONE=$(echo "$i" | jq -r '.[0]') | |
NAME_ZONE=$(echo "$i" | jq -r '.[1]') | |
echo "Zone id: ${ID_ZONE}" | |
echo "Name: ${NAME_ZONE}" | |
echo "Changing ${OPTION} to ${VALUE} ..." | |
curl -s -X PATCH "https://api.cloudflare.com/client/v4/zones/${ID_ZONE}/settings/${OPTION}" \ | |
-H "X-Auth-Email: ${ACCOUNT_EMAIL}" \ | |
-H "X-Auth-Key: ${GLOBAL_API_KEY}" \ | |
-H "Content-Type:application/json" --data "{\"id\":\"${OPTION}\",\"value\":\"${VALUE}\"}" | jq | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment