Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

无法解析加密信息 #52

Open
jiwan2004 opened this issue Sep 25, 2016 · 3 comments
Open

无法解析加密信息 #52

jiwan2004 opened this issue Sep 25, 2016 · 3 comments

Comments

@jiwan2004
Copy link

2016-09-25 21:20:34 INFO Config:66 - load wechat4j.properties success
不清楚代码哪里有加密解密的处理。
Log 如下:

2016-09-25 21:20:34 INFO WechatSupport:114 - parse post data:


2016-09-25 21:20:34 INFO WechatSupport:128 - distributeMessage start
2016-09-25 21:20:34 INFO WechatSupport:130 - msgType is null
九月 25, 2016 9:20:34 下午 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet [dispatcher] in context with path [/wechat] threw exception [Request processing failed; nested exception is java.lang.NullPointerException: Name is null] with root cause
java.lang.NullPointerException: Name is null

@jiwan2004
Copy link
Author

使用微信测试接口发送数据,兼容模式都可以看到明文。改为安全模式,无法使用

@sionsxie
Copy link

java权限策略问题 官方例子加密例子里有的

AES KeySize异常解决方案

如果出现异常java.security.InvalidKeyException:illegal Key Size,在官方网站下载JCE无限制权限策略文件,解压后拷贝local_policy.jar和US_export_policy.jar到
<%JRE%>\lib\security目录下覆盖原来的文件。

@sionsxie
Copy link

还有就是WechatSupport类里没有对加密解密相关的做处理要自己写

`/**
* wechat调用入口,进行数据接收,事件分发
* @return
*/
public String execute(){
logger.debug("WechatSupport run");
SignatureParam param = new SignatureParam(request);
String signature =param.getSignature();
String timestamp = param.getTimestamp();
String nonce = param.getNonce();
String echostr = param.getEchostr();
String encrypt_type = request.getParameter(ENCRYPT_TYPE);
String token = Config.instance().getToken();

	ValidateSignature validateSignature = new ValidateSignature(signature, 
			timestamp, nonce, token);
	//////////////////////////////// 修改部分
	if(!validateSignature.check()){
		return "error";
	}
	if(StringUtils.isNotBlank(echostr)){
 		return echostr;
	}
	//分发消息,得到响应
	String result;
	if(StringUtils.equals(encrypt_type, "aes")){//aes方式加解密
		result = dispatchSign(timestamp, nonce);
	}else{
		result = dispatch();
	}
	logger.info("response data:" + result);
	////////////////////////////////
	return result;
}`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants