Senparc/NeuChar

没有捕获的异常

xjaja opened this issue · 6 comments

xjaja commented

this.EcryptRequestDocument.Save(Path.Combine(logPath, string.Format("{0}_Request_Ecrypt_{1}_{2}.txt", _getRandomFileName(),

开启
messageHandler.SaveResponseMessageLog();//记录 Response 日志(可选)

当发送过来的消息是加密的时候这里会报 NullReferenceException 。

@xjaja 你的输入的XML的日志可以发一下吗?

xjaja commented

<xml> <ToUserName><![CDATA[wx41ca876f0d7dbf12]]></ToUserName> <Encrypt><![CDATA[+IG3Nvwhymnx5PeD6QTle31Ngny+EOMF6UGQkyo1QsoehpdSXkTAMXPx39g8S7/WNwz5L9zPxJ4e3WxUlp2SwWwVXROh2vrdPtBGDHuoiApXucrsvoKCJ25pY2A62/MDhS51mr1ksZtSRq6ERK6LFMJxHMm3fr/g1EkApykNgwxDJLTyqTl1r51TF/PSu2T84R7ntgqqwCdY4bpN77WUf7qtA+X1evtxtHrhwwIlh3fuNSEe8M5jkciGFoUwM4d4xuv6MAWDqINqrrgKrLYoaGtRxOsLpGK9JYwMSbjjQpOHhRhq8OUcqTh7cHUnhluCL/89JtUOCQUXGlZZE1gv+ESKyH21N8mKUibiY1lxiTK2YlBPcv2ppAxHrk4pSKcBGOxeRLHnPI0m3HW36+CeCtTV16+ZTqQRx/W8GS3NosgueqE17FH+h9VCmv71RxxtX5+CtaGiLPuZZXc7sjiEyNrbwlZWyL23Lqpp3dH47gREcB0zPqQNpH5m6Jb33Rv3]]></Encrypt> </xml>

if (this.RequestDocument!=null)
{
this.RequestDocument.Save(Path.Combine(logPath, string.Format("{0}_Request_{1}_{2}.txt", _getRandomFileName(),
this.RequestMessage?.FromUserName,
this.RequestMessage?.MsgType)));
}

if (this.UsingEncryptMessage && this.EcryptRequestDocument != null)
{
this.EcryptRequestDocument.Save(Path.Combine(logPath, string.Format("{0}_Request_Ecrypt_{1}_{2}.txt", _getRandomFileName(),
this.RequestMessage.FromUserName,
this.RequestMessage.MsgType)));
}

上面未加密部分处理了,下面加密的没处理

<xml> <ToUserName><![CDATA[wx41ca876f0d7dbf12]]></ToUserName> <Encrypt><![CDATA[+IG3Nvwhymnx5PeD6QTle31Ngny+EOMF6UGQkyo1QsoehpdSXkTAMXPx39g8S7/WNwz5L9zPxJ4e3WxUlp2SwWwVXROh2vrdPtBGDHuoiApXucrsvoKCJ25pY2A62/MDhS51mr1ksZtSRq6ERK6LFMJxHMm3fr/g1EkApykNgwxDJLTyqTl1r51TF/PSu2T84R7ntgqqwCdY4bpN77WUf7qtA+X1evtxtHrhwwIlh3fuNSEe8M5jkciGFoUwM4d4xuv6MAWDqINqrrgKrLYoaGtRxOsLpGK9JYwMSbjjQpOHhRhq8OUcqTh7cHUnhluCL/89JtUOCQUXGlZZE1gv+ESKyH21N8mKUibiY1lxiTK2YlBPcv2ppAxHrk4pSKcBGOxeRLHnPI0m3HW36+CeCtTV16+ZTqQRx/W8GS3NosgueqE17FH+h9VCmv71RxxtX5+CtaGiLPuZZXc7sjiEyNrbwlZWyL23Lqpp3dH47gREcB0zPqQNpH5m6Jb33Rv3]]></Encrypt> </xml>

if (this.RequestDocument!=null)
{
this.RequestDocument.Save(Path.Combine(logPath, string.Format("{0}_Request_{1}_{2}.txt", _getRandomFileName(),
this.RequestMessage?.FromUserName,
this.RequestMessage?.MsgType)));
}

if (this.UsingEncryptMessage && this.EcryptRequestDocument != null)
{
this.EcryptRequestDocument.Save(Path.Combine(logPath, string.Format("{0}_Request_Ecrypt_{1}_{2}.txt", _getRandomFileName(),
this.RequestMessage.FromUserName,
this.RequestMessage.MsgType)));
}

上面未加密部分处理了,下面加密的没处理

需要发一下解密后的。

xjaja commented

<xml> <ToUserName><![CDATA[wx41ca876f0d7dbf12]]></ToUserName> <Encrypt><![CDATA[+IG3Nvwhymnx5PeD6QTle31Ngny+EOMF6UGQkyo1QsoehpdSXkTAMXPx39g8S7/WNwz5L9zPxJ4e3WxUlp2SwWwVXROh2vrdPtBGDHuoiApXucrsvoKCJ25pY2A62/MDhS51mr1ksZtSRq6ERK6LFMJxHMm3fr/g1EkApykNgwxDJLTyqTl1r51TF/PSu2T84R7ntgqqwCdY4bpN77WUf7qtA+X1evtxtHrhwwIlh3fuNSEe8M5jkciGFoUwM4d4xuv6MAWDqINqrrgKrLYoaGtRxOsLpGK9JYwMSbjjQpOHhRhq8OUcqTh7cHUnhluCL/89JtUOCQUXGlZZE1gv+ESKyH21N8mKUibiY1lxiTK2YlBPcv2ppAxHrk4pSKcBGOxeRLHnPI0m3HW36+CeCtTV16+ZTqQRx/W8GS3NosgueqE17FH+h9VCmv71RxxtX5+CtaGiLPuZZXc7sjiEyNrbwlZWyL23Lqpp3dH47gREcB0zPqQNpH5m6Jb33Rv3]]></Encrypt> </xml>

if (this.RequestDocument!=null)
{
this.RequestDocument.Save(Path.Combine(logPath, string.Format("{0}_Request_{1}_{2}.txt", _getRandomFileName(),
this.RequestMessage?.FromUserName,
this.RequestMessage?.MsgType)));
}

if (this.UsingEncryptMessage && this.EcryptRequestDocument != null)
{
this.EcryptRequestDocument.Save(Path.Combine(logPath, string.Format("{0}_Request_Ecrypt_{1}_{2}.txt", _getRandomFileName(),
this.RequestMessage.FromUserName,
this.RequestMessage.MsgType)));
}

上面未加密部分处理了,下面加密的没处理

需要发一下解密后的。

没有解密就异常了。

https://mp.weixin.qq.com/debug/

接受文本消息,微信发送过来的消息使用本地密钥解密失败时记录请求日志就会异常。

@xjaja 有一种可能是没有解密成功。您是公众号还是小程序或其他?

长时间没有答复,先关闭了。