This commit is contained in:
@@ -22,21 +22,18 @@ in
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Verify a raw PIA API response (line 1 = JSON, lines 3+ = base64 RSA-SHA256 signature).
|
# Debug: log what comes after line 1 in a PIA API response.
|
||||||
verifyPIAResponse() {
|
verifyPIAResponse() {
|
||||||
local raw=$1 label=$2
|
local raw=$1 label=$2
|
||||||
local sig_file
|
local line_count trailing
|
||||||
sig_file=$(mktemp)
|
line_count=$(echo "$raw" | wc -l)
|
||||||
echo "$raw" | tail -n +3 | base64 -d > "$sig_file"
|
echo "DEBUG $label: response has $line_count line(s)"
|
||||||
if ! echo -n "$(echo "$raw" | head -n 1 | tr -d '\n')" | \
|
if [[ "$line_count" -gt 1 ]]; then
|
||||||
openssl dgst -sha256 -verify "${pubKeyPath}" \
|
trailing=$(echo "$raw" | tail -n +2)
|
||||||
-signature "$sig_file"; then
|
echo "DEBUG $label: trailing data: $trailing"
|
||||||
echo "ERROR: $label signature verification failed" >&2
|
else
|
||||||
rm -f "$sig_file"
|
echo "DEBUG $label: no trailing data (single-line response)"
|
||||||
return 1
|
|
||||||
fi
|
fi
|
||||||
echo "$label signature verified"
|
|
||||||
rm -f "$sig_file"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchPIAToken() {
|
fetchPIAToken() {
|
||||||
|
|||||||
Reference in New Issue
Block a user