From 7a89de8bbdec82ee384d8f0db20e78a276db3bd1 Mon Sep 17 00:00:00 2001 From: Whispering Wind <151555003+ReturnFI@users.noreply.github.com> Date: Fri, 11 Apr 2025 13:24:03 +0330 Subject: [PATCH] Convert pinSHA256 from base64 to hex in config.json --- upgrade.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/upgrade.sh b/upgrade.sh index 5c1f67d..c1d7957 100644 --- a/upgrade.sh +++ b/upgrade.sh @@ -117,6 +117,23 @@ else echo "$NORMALSUB_ENV not found. Skipping SUBPATH check." fi +CONFIG_FILE="/etc/hysteria/config.json" +if [ -f "$CONFIG_FILE" ]; then + echo "Checking and converting pinSHA256 format in config.json" + + if grep -q "pinSHA256.*=" "$CONFIG_FILE"; then + echo "Converting pinSHA256 from base64 to hex format" + + HEX_FINGERPRINT=$(openssl x509 -noout -fingerprint -sha256 -inform pem -in /etc/hysteria/ca.crt | sed 's/.*=//;s///g') + + sed -i "s|\"pinSHA256\": \"sha256/.*\"|\"pinSHA256\": \"$HEX_FINGERPRINT\"|" "$CONFIG_FILE" + + echo "pinSHA256 converted to hex format: $HEX_FINGERPRINT" + else + echo "pinSHA256 appears to already be in hex format or not present, no conversion needed" + fi +fi + echo "Setting ownership and permissions" chown hysteria:hysteria /etc/hysteria/ca.key /etc/hysteria/ca.crt chmod 640 /etc/hysteria/ca.key /etc/hysteria/ca.crt