收藏
回答

错误的签名,验签失败

{"code":"SIGN_ERROR","detail":{"detail":{"issue":"sign not match"},"field":"signature","location":"authorization","sign_information":{"method":"POST","sign_message_length":334,"truncated_sign_message":"POST\n/v3/fund-app/mch-transfer/transfer-bills\n1736994722\na2d8f3c28a484de8b418d800b46082cd\n{\"appid\"\n","url":"/v3/fund-app/mch-transfer/transfer-bills"}},"message":"错误的签名,验签失败"}

一直显示错误的签名,用官方的SDK还是自己写的,都是一样的问题。。真不知道错哪了

回答关注问题邀请回答
收藏

2 个回答

  • 无字佚名
    无字佚名
    01-18

    已解决问题了。。未用官方的SDK,自己写的签名算法。问题的主要原因还是Http的Body未指定UTF-8的编码。

    CloseableHttpClient client = HttpClients.createDefault();
    HttpPost post = new HttpPost(url);
    post.setHeader("Authorization", authorization);
    post.setHeader("Accept", "application/json");
    post.setHeader("Wechatpay-Serial", merchantSerialNumber);
    post.setHeader("Content-Type", "application/json");
    
    // 之前就是这里未指定UTF-8编码,造成签名错误
    StringEntity stringEntity = new StringEntity(jsonInputString, ContentType.APPLICATION_JSON, "UTF-8", false);
    post.setEntity(stringEntity);
    
    CloseableHttpResponse response = client.execute(post);
    HttpEntity entity = response.getEntity();
    String resData = EntityUtils.toString(entity);
    
    01-18
    有用
    回复
  • Memory
    Memory
    01-16

    用的哪个sdk ?贴代码

    01-16
    有用
    回复 1
    • 无字佚名
      无字佚名
      01-18
      没用SDK,自己写的签名算法。。不过已经解决了问题了。问题的原因是我的传入的http的body参数没有经过UTF-8的设置,导致腾讯后台收到的是乱码造成的问题
      01-18
      回复
登录 后发表内容