请问下你的这个问题解决了吗
微信服务端api签名指南,一直出现签名错误?public static string RSASignPEM(string data, string privateKeyPEM, string hashAlgorithm = "MD5", string encoding = "UTF-8") { byte[] pemkey = Convert.FromBase64String(privateKeyPEM); RSACryptoServiceProvider RSA = DecodeRSAPrivateKey(privateKeyPEM);//function to parse .pem file RSAParameters rsaParams = RSA.ExportParameters(true); RSACng RSACng = new RSACng(); RSACng.ImportParameters(rsaParams); var dataBytes = Encoding.GetEncoding(encoding).GetBytes(data); byte[] signature = RSACng.SignData(dataBytes, HashAlgorithmName.SHA256,RSASignaturePadding.Pss); return Convert.ToBase64String(signature); } /// <summary> /// RSA私钥格式转换 /// </summary> /// <param name="privateKey"></param> /// <returns></returns> private static RSACryptoServiceProvider DecodeRSAPrivateKey(string privateKey) { var privateKeyBits = System.Convert.FromBase64String(privateKey); var RSA = new RSACryptoServiceProvider(); var RSAparams = new RSAParameters(); using (BinaryReader binr = new BinaryReader(new MemoryStream(privateKeyBits))) { byte bt = 0; ushort twobytes = 0; twobytes = binr.ReadUInt16(); if (twobytes == 0x8130) binr.ReadByte(); else if (twobytes == 0x8230) binr.ReadInt16(); else throw new Exception("Unexpected value read binr.ReadUInt16()"); twobytes = binr.ReadUInt16(); if (twobytes != 0x0102) throw new Exception("Unexpected version"); bt = binr.ReadByte(); if (bt != 0x00) throw new Exception("Unexpected value read binr.ReadByte()"); RSAparams.Modulus = binr.ReadBytes(GetIntegerSize(binr)); RSAparams.Exponent = binr.ReadBytes(GetIntegerSize(binr)); RSAparams.D = binr.ReadBytes(GetIntegerSize(binr)); RSAparams.P = binr.ReadBytes(GetIntegerSize(binr)); RSAparams.Q = binr.ReadBytes(GetIntegerSize(binr)); RSAparams.DP = binr.ReadBytes(GetIntegerSize(binr)); RSAparams.DQ = binr.ReadBytes(GetIntegerSize(binr)); RSAparams.InverseQ = binr.ReadBytes(GetIntegerSize(binr)); } RSA.ImportParameters(RSAparams); return RSA; } private static int GetIntegerSize(BinaryReader binr) { byte bt = 0; byte lowbyte = 0x00; byte highbyte = 0x00; int count = 0; bt = binr.ReadByte(); if (bt != 0x02) return 0; bt = binr.ReadByte(); if (bt == 0x81) count = binr.ReadByte(); else if (bt == 0x82) { highbyte = binr.ReadByte(); lowbyte = binr.ReadByte(); byte[] modint = { lowbyte, highbyte, 0x00, 0x00 }; count = BitConverter.ToInt32(modint, 0); } else { count = bt; } while (binr.ReadByte() == 0x00) { count -= 1; } binr.BaseStream.Seek(-1, SeekOrigin.Current); return count; } C#,这是签名方法,签名后一直提示签名错误 String url_path = ctx["url_path"].ToString(); int reqTs = req["req_ts"].ObjectToInt(); String reqData = req["req_data"].ToString(); String payload = url_path + "\n" + local_appid + "\n" + reqTs + "\n" + reqData; RSASignPEM(payload, local_private_key); //这里证书用的是直接下载的证书,一直提示签名错误,也不知道哪里出错了。
04-10同问,这个问题解决了没
服务端api签名的问题,一直errcode: 40234,啥问题?麻烦帮我查一下是什么问题 appid: "wx829f23c263fac0ea" 错误: { errcode: 40234, errmsg: 'invalid signature rid: 6597a8c3-542f4d5e-056c9cc3' }
04-10不知道楼主解决了这个问提没有,我的也是,这久迁移到另外一台服务器上,发现不能回调了,之前还是好好的
小程序支付无法回调https地址做小程序开发用到小程序支付功能,现在发现一个问题 支持成功后,会异步回调https协议的回调地址(确定这个地址外网可以访问),发现无法回调,改成http协议就正常(说明支付相应的设置没有问题) 但是,经测试,在其他的服务器上,发现https和http回调都正常,这说明是支付回调是可以回调https地址的 通过以上分析,个人认为可能是以下2个原因造成的: 1)服务器的问题,是服务器屏蔽了https访问 通过测速网站测试https网址,发现电信、移动、联通等都可以访问,说明服务器没有屏蔽https协议 2)https证书存在问题 通过腾讯的https在线分析工具,也是正常的 以上2个原因都被排除掉了,各位大神有没有碰到类似的问题,是什么原因造成的,如何解决的?
2018-08-24