https://pay.weixin.qq.com/docs/merchant/development/interface-rules/signature-verification.html
我是参考这个文档里说明来验证签名,用程序和openssl都试过,验证失败
先导出的公钥
openssl x509 -in D:\cert\apiclient_cert.pem -pubkey -out D:\cert\apiclient_pub.pem
然后使用 base64 解码应答签名,in.txt里存的是通知回调中Request["HTTP_WECHATPAY_SIGNATURE"]参数
openssl base64 -d -A -in d:\in.txt -out d:\out.txt
最后验证签名
openssl dgst -sha256 -verify D:\cert\apiclient_pub.pem -signature d:\out.txt d:\v.txt
执行之后提示
Verification failure
00370000:error:0200008A:rsa routines:RSA_padding_check_PKCS1_type_1:invalid padding:crypto\rsa\rsa_pk1.c:79:
00370000:error:02000072:rsa routines:rsa_ossl_public_decrypt:padding check failed:crypto\rsa\rsa_ossl.c:746:
00370000:error:1C880004:Provider routines:rsa_verify:RSA lib:providers\implementations\signature\rsa_sig.c:785:
谁教你这样获取公钥验证签名的?你再看看文档写的是要求用什么证书