Giter Site home page Giter Site logo

消息加密参数 about wxjava HOT 5 CLOSED

wechat-group avatar wechat-group commented on June 23, 2024
消息加密参数

from wxjava.

Comments (5)

binarywang avatar binarywang commented on June 23, 2024

不太明白你的意思,“发现微信的 signature是用token,timestamp和noncestr三个参数计算的,与其文档里的说明并不一致” 这句话怎么理解?

from wxjava.

binarywang avatar binarywang commented on June 23, 2024

我感觉你应该是概念上有所混淆导致这个问题,WxCryptUtil是消息加密用的,而signature是校验消息来源的,不是一个东西

from wxjava.

fuqiangdong01 avatar fuqiangdong01 commented on June 23, 2024

`
try {

  WxMpXmlMessage xmlMessage = WxMpXmlMessage.fromEncryptedXml(message, wxMpService.getWxMpConfigStorage(),timestamp, nonce, signature);

  if (WxConsts.XML_MSG_DEVICE_EVENT.equals(xmlMessage.getMsgType())) {

    if (LOG.isDebugEnabled()) {
      LOG.debug("device event");
    }

    String openId = xmlMessage.getFromUser();
    String deviceId = xmlMessage.getDeviceId();
    rentalService.bindDevice(deviceId, openId);

  }
} catch (Exception e) {

  LOG.warn(e.getMessage());

}

我是这样调用的。报错:WARN RootController:186 - 加密消息签名校验失败`
debug时,发现SHA1.gen(new String[]{this.token, timeStamp, nonce,cipherText})计算的结果与signature不一致,若只用前三个参数计算token,timeStamp,nonce计算,则与微信的signature一致。

from wxjava.

binarywang avatar binarywang commented on June 23, 2024

你确实是搞错了,signature那个是验证消息是否是微信服务器发送过来用的。建议你参考下demo中的实现方法,具体看首页中提供的几个demo即可,或者看wiki中的相关内容

from wxjava.

fuqiangdong01 avatar fuqiangdong01 commented on June 23, 2024

是的,是我搞错了。这个位置,我应该使用msg_signature。在向微信测试号的请求里,并没有msg_signature这个参数。哭

from wxjava.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.