v1.5.119
Changelog
v1.5.119
Fix: Alipay V3 Signature Verification Failure with AES Encryption
When aesKey is set for content encryption, Alipay signs the ciphertext response, but the SDK was verifying the signature against the decrypted plaintext, causing crypto/rsa: verification error.
What Changed
client.go: AddedrawBodyForSignfield to preserve the original response body before decryption.request.go: Save the raw ciphertext before AES decryption; removed dependency on thealipay-content-encryptresponse header (some APIs return encrypted content without this header, causing decryption to be skipped).sign.go:autoVerifySignByCertnow uses the raw ciphertext for signature verification when AES encryption is enabled, instead of the decrypted plaintext.
Correct Verification Flow
Alipay returns: ciphertext body + signature (signed over ciphertext)
↓
doPost: save ciphertext → rawBodyForSign, decrypt → plaintext body
↓
autoVerifySignByCert: verify signature using rawBodyForSign (ciphertext) ✅
↓
API method: json.Unmarshal(plaintext body) to parse business data
Files Changed
alipay/v3/client.goalipay/v3/request.goalipay/v3/sign.go
Full Changelog: v1.5.118...v1.5.119