- C#一直签名有问题,有没有相关的示例
,二种签名都试过,也用过SKIT带的SM2withsm3等,一直提示不对 https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/getting_started/api_signature.htmlhttps://developers.weixin.qq.com/miniprogram/dev/framework/server-ability/backend-api.html
2023-07-25 - 微信服务端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); //这里证书用的是直接下载的证书,一直提示签名错误,也不知道哪里出错了。
2023-07-24 - 类目不符行为
请问下菜谱视频制作方法相关需要什么分类.视频类的是不是也要申请什么功能
2021-11-08 - 小程序存在信息安全风险的提醒?
你好,经平台验证,你的小程序对违法违规等不当信息的过滤机制不够完善,极有可能因此违反《微信小程序平台运营规范》5.行为规范-5.18内容安全等相关规定。请加强提升小程序的信息安全防护能力,降低被恶意利用导致传播恶意内容的风险。平台会对你的小程序再次进行信息安全风险验证,如果在2020-03-06 13:35:52前仍然存在信息安全风险,平台将会停止向你的小程序提供“被搜索”的服务。平台建议调用内容安全监测接口校验文本/图片是否含有敏感内容,降低被恶意利用导致传播恶意内容的风险。参考接口: https://mp.weixin.qq.com/cgi-bin/announce?action=getannouncement&key=11522142966rk3L2&version=1&lang=zh_CN&platform=2 你好,我确定做了文字和图片的上传过滤,现在找不到具体问题在哪,麻烦你们能仔细说一下具体原因吗.谢谢
2020-03-04