调用接口的相关代码
生成签名的方法用的是官方文档中的示例
返回的结果
如果注释掉
httpPost.setHeader("Authorization","WECHATPAY2-SHA256-RSA2048 "+sign);
这一行,返回的结果是
401{"code":"SIGN_ERROR","detail":{"detail":{"issue":"sign not match"},"field":"signature","location":"authorization","sign_information":{"method":"POST","sign_message_length":1560,"truncated_sign_message":"POST\n/v3/marketing/busifavor/stocks\n1619420575\n4fUwao3ueJNcW5A6icGbkz1951xFzHgU\n{\"stock_\n","url":"/v3/marketing/busifavor/stocks"}},"message":"错误的签名,验签失败"}
消息头Authorization的信息是
WECHATPAY2-SHA256-RSA2048 mchid="商户号",nonce_str="sdfj934ytg436ssa346edhjk",timestamp="1619408921",serial_no="证书序列号",signature="q9MAABLeESEd2IriNOabJt5t3stEmMksF4J0DR4BP/GIEa5vGIjwAhWL52muVkORK/+V5BTkAVoPlqlSPWUOhWforUl1+SaaHQVCgE41FLfUjbOezqE6aFObUqWlkVQ9ZFG19aaVeNARcOBFzgKBWBidrjnoj5ukSi59UgY+Fdy4vwy7azmiw7u8Ag7kujhR+AkXQEYT7bWJLXGEAvpy9h1OH5pPNjvUHoD8PM6o9YTkpJbn1TVaElUN7c6Ly4b7725UBWSOK1gg2VZEF8dzOrTV2I7X1rcABEwgpQ0i5bJ0s3E/omSarCs1Ivlr9IDdSLI+DZfcVfczj/0M1Ujffg=="