Skip to content

Commit 1005f3c

Browse files
chore: fix sign bug
1 parent a565ce3 commit 1005f3c

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

volcenginesdkcore/signv4.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,19 +128,21 @@ def sign_url(path, method, query, ak, sk, region, service, session_token=None, h
128128

129129
# Generate X-SignedQueries BEFORE adding X-Security-Token
130130
query['X-SignedQueries'] = ';'.join(sorted(query.keys()))
131+
signed_query_keys = set(query.keys())
131132

132133
# X-Security-Token must be added AFTER X-SignedQueries calculation
133134
if session_token:
134135
query['X-Security-Token'] = session_token
135136

136137
# Build canonical request
137138
body_hash = hashlib.sha256(b'').hexdigest()
139+
canonical_query_params = {k: v for k, v in query.items() if k in signed_query_keys}
138140

139141
if sign_host:
140142
canonical_request = '\n'.join([
141143
method,
142144
path,
143-
SignerV4.canonical_query(query),
145+
SignerV4.canonical_query(canonical_query_params),
144146
'host:' + host + '\n',
145147
'host',
146148
body_hash
@@ -149,7 +151,7 @@ def sign_url(path, method, query, ak, sk, region, service, session_token=None, h
149151
canonical_request = '\n'.join([
150152
method,
151153
path,
152-
SignerV4.canonical_query(query),
154+
SignerV4.canonical_query(canonical_query_params),
153155
'\n',
154156
'',
155157
body_hash

0 commit comments

Comments
 (0)