- 个别苹果手机小程序提示证书无效,请解?
服务器证书未到期,证书状态正常!个别手机出现这个错误提示,求解? [图片]
01-25 - 微信同城配送使用沙箱环境返回错误,请问需要注意什么?
{"wx_store_id":null,"wx_order_id":null,"store_order_id":null,"service_trans_id":null,"distance":0,"trans_order_id":null,"waybill_id":null,"fee":0,"fetch_code":null,"order_seq":null,"errcode":934019,"errmsg":"用户超出配送范围 rid: 65a50e15-42e3d078-23ac3dc8"} 使用沙箱环境提交派送订单,接口返回,请问需要注意什么吗?
01-15 - 微信小程序同城配送修改了密钥后平台证书会不会受影响?
请问 微信小程序同城配送修改了密钥后,MP上的平台证书会不会受影响? 还有数据做了签名后,能否自己 执行下一步做验签以校验签名 是否正确?
01-08 - 微信同城配送数据加密,一直报签名问题,有哪位大侠指点一下?
//此处走JAVA服务,签名数据 string HttpSignData(string action, string data) { var req = HttpWebRequest.Create("http://127.0.0.1:8080/myweb/hello-servlet?action=" + action); req.Method = "POST"; req.ContentType = "appliction/json"; var buf = Encoding.UTF8.GetBytes(data); using (var sw = req.GetRequestStream()) { sw.Write(buf, 0, buf.Length); } var str = ""; using (var stream = req.GetResponse().GetResponseStream()) { using (var sr = new StreamReader(stream)) { str = sr.ReadToEnd(); } } return str; } private void button1_Click(object sender, EventArgs e) { var strLog = new StringBuilder(); //配置信息 var config = new WxConfig(); //当前页面路径 var urlpath = "https://api.xjshw.com/wxa/getuserriskrank";// "http://localhost:28085/Default2";// Request.Url.AbsoluteUri; //额外数据 var aad = urlpath + "|" + WxConfig.appid + "|" + config.timestamp + "|" + WxConfig.aes_sn; #region 日志 strLog.Append("\r\n-----------数据:\r\n"); strLog.Append("iv:" + config.iv + "\r\n"); strLog.Append("nonce:" + config.nonce + "\r\n"); strLog.Append("timestamp:" + config.timestamp + "\r\n"); strLog.Append("appid:" + WxConfig.appid + "\r\n"); strLog.Append("sn:" + WxConfig.aes_sn + "\r\n\r\n"); strLog.Append("额外数据:" + aad + "\r\n\r\n"); #endregion #region 请求数据包明文 dynamic data = new ExpandoObject(); data.wx_store_id = "4000000000000650042"; data._n = config.nonce; data._appid = WxConfig.appid; data._timestamp = config.timestamp; #endregion //将请求的数据对象转成JSON字符串 var plaintext = Newtonsoft.Json.JsonConvert.SerializeObject(data); strLog.Append("请求数据:" + plaintext + "\r\n\r\n"); #region 加密数据-AES256_GCM //GCM模式输出的认证信息,使用base64编码 //AES256_GCM 方式加密数据 var aesResultBuff = AesGcmHelper.AesGcmEncrypt(plaintext, WxConfig.aes_key, config.iv, aad);// associatedData); #region java方式加密 var sss = HttpSignData("encryption", Newtonsoft.Json.JsonConvert.SerializeObject(new { plaintext = plaintext, key = WxConfig.aes_key, iv = config.iv, aad = aad })); var jsonObj = (JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(sss); var a = jsonObj.Value<String>("data").ToString(); var b = jsonObj.Value<String>("authtag").ToString(); var c = jsonObj.Value<String>("iv").ToString(); #endregion #region 测试解密数据 var dataBuff = Convert.FromBase64String(a);// (aesResultBuff.EncryptedData); var authBuff = Convert.FromBase64String(b);// (aesResultBuff.AuthTag); var rawBuff = new byte[dataBuff.Length + authBuff.Length]; Array.Copy(dataBuff, 0, rawBuff, 0, dataBuff.Length); Array.Copy(authBuff, 0, rawBuff, dataBuff.Length, authBuff.Length); // var rawBase64Str = Convert.ToBase64String(rawBuff); var decryptData = AesGcmHelper.AesGcmDecrypt(rawBuff, WxConfig.aes_key, config.iv, aad);// associatedData); #endregion strLog.Append("-----------加密:\r\n\r\n");// + Newtonsoft.Json.JsonConvert.SerializeObject(data) + "\r\n\r\n"); strLog.Append("加密数据:" + a + "\r\n\r\n"); strLog.Append("授权标签:" + b + "\r\n\r\n"); #endregion #region 发送的数据包对象 var reqData = new { iv = config.iv,//加密向量 data = aesResultBuff.EncryptedData,//加密数据 authtag = aesResultBuff.AuthTag//授权标签 }; #endregion //转JSON字符串 var reqDataJsonStr = Newtonsoft.Json.JsonConvert.SerializeObject(reqData); strLog.Append("-----------发送的数据包:" + reqDataJsonStr + "\r\n\r\n"); strLog.Append("-----------签名:\r\n\r\n"); #region 数量签名 //签名字段格式 //开发者需先拼接待签名串,使用 urlpath\n appid\n timestamp\n postdata 格式,字段之间使用换行符\n做分隔符。 //待签名数据 var payload = urlpath + "\n" + WxConfig.appid + "\n" + config.timestamp + "\n" + reqDataJsonStr; strLog.Append("待签名数据:" + payload + "\r\n\r\n"); //开始签名 var payloadSigned = this.HttpSignData("sign", payload); strLog.Append("签名结果:" + payloadSigned + "\r\n\r\n"); #endregion #region 封装网络请求对象 var access_token = Senparc.Weixin.MP.CommonAPIs.AccessTokenContainer.TryGetToken(WxConfig.appid, WxConfig.appsecret, true); var url = "https://api.weixin.qq.com/cgi-bin/express/intracity/querystore?access_token=" + access_token; var req = WebRequest.CreateHttp(url); req.Method = "POST"; req.ContentType = "application/json;charset=utf-8"; req.Accept = "application/json"; //req.Referer = urlpath; #endregion #region 设置请求头-添加签名信息 req.Headers.Add("Wechatmp-Appid", WxConfig.appid); req.Headers.Add("Wechatmp-TimeStamp", config.timestamp.ToString()); req.Headers.Add("Wechatmp-Signature", payloadSigned); strLog.Append("-----------请求头:\r\n\r\n"); strLog.Append("Wechatmp-Appid:" + WxConfig.appid + "\r\n\r\n"); strLog.Append("Wechatmp-TimeStamp:" + config.timestamp + "\r\n\r\n"); strLog.Append("Wechatmp-Signature:" + payloadSigned + "\r\n\r\n"); #endregion //待发送的缓存区 var reqDataBytes = Encoding.UTF8.GetBytes(reqDataJsonStr); //发送数据 using (var sr = req.GetRequestStream()) { sr.Write(reqDataBytes, 0, reqDataBytes.Length); } var content = ""; using (var stream = req.GetResponseAsync().Result.GetResponseStream()) { using (var sr = new StreamReader(stream)) { content = sr.ReadToEnd(); } } strLog.Append("-----------微信返回:\r\n\r\n"); strLog.Append(content); textBox1.Text = strLog.ToString(); // Label1.Text = strLog.ToString(); ---------------------------------------------------aes加密解密 using System; using System.Collections.Generic; using System.Linq; using System.Security.Cryptography; using System.Text; using System.Threading.Tasks; using Org.BouncyCastle.Crypto.Engines; using Org.BouncyCastle.Crypto.Modes; using Org.BouncyCastle.Crypto.Parameters; namespace Hidistro.Core { /// <summary> /// 此加密算法和微信提供的加密算法结果一致 /// </summary> public class AesGcmResult { /// <summary> /// 加密数据 /// </summary> public string EncryptedData { get; set; } /// <summary> /// 授权标签 /// </summary> public string AuthTag { get; set; } } public class AesGcmHelper { /// <summary> /// AES GCM加密 /// </summary> /// <param name="plainText">加密数据</param> /// <param name="base64Key">加密KEY,BASE64编码</param> /// <param name="base64Iv">随机数,BASE64编码</param> /// <param name="associatedData">aad 额外数据</param> /// <returns></returns> public static /*byte[]*/ AesGcmResult AesGcmEncrypt(string plainText, string base64Key, string base64Iv, string aad = null)// byte[] associatedData = null) { byte[] realPlaintext = Encoding.UTF8.GetBytes(plainText); byte[] key = Convert.FromBase64String(base64Key);// Encoding.UTF8.GetBytes(aesKey); var realIv = Convert.FromBase64String(base64Iv);// "aFYXNjnWubVjvhqh"); var cipher = new GcmBlockCipher(new AesEngine());// AesFastEngine());// byte[] associatedData = null; if (!string.IsNullOrWhiteSpace(aad)) { associatedData = Encoding.UTF8.GetBytes(aad); } AeadParameters parameters = new AeadParameters(new KeyParameter(key), 128, realIv, associatedData); cipher.Init(true, parameters); byte[] ciphertext = new byte[cipher.GetOutputSize(plainText.Length)]; int len = cipher.ProcessBytes(realPlaintext, 0, realPlaintext.Length, ciphertext, 0); //这个库加密完成会直接把tag放在密文最后面,因此,加解密不需要关注tag,跟其他库不太一致,需要注意下 cipher.DoFinal(ciphertext, len); byte[] encryptedData = new byte[ciphertext.Length - 16]; //取出授权标签数据部分 byte[] authTag = new byte[16]; Array.Copy(ciphertext, 0, encryptedData, 0, ciphertext.Length - 16); Array.Copy(ciphertext, ciphertext.Length - 16, authTag, 0, 16); //base64编码 var encryptedDataStr = Convert.ToBase64String(encryptedData); var authtag = Convert.ToBase64String(authTag); return new AesGcmResult { EncryptedData = encryptedDataStr, AuthTag = authtag }; } /// <summary> /// 解密数据 /// </summary> /// <param name="data"></param> /// <param name="aesKey"></param> /// <param name="iv"></param> /// <param name="associatedData"></param> /// <returns></returns> public static String AesGcmDecrypt(/*string data,*/byte[] ciphertextbyte, string base64Key, string base64IV, string aad = null)// byte[] associatedData = null) { byte[] key = Convert.FromBase64String(base64Key);// Encoding.UTF8.GetBytes(aesKey); byte[] nonce = Convert.FromBase64String(base64IV);// new byte[12]; byte[] associatedData = null; if (!string.IsNullOrWhiteSpace(aad)) { associatedData = Encoding.UTF8.GetBytes(aad); } GcmBlockCipher cipher = new GcmBlockCipher(new AesEngine()); AeadParameters parameters = new AeadParameters(new KeyParameter(key), 128, nonce, associatedData); cipher.Init(false, parameters); byte[] decryptedData = new byte[cipher.GetOutputSize(ciphertextbyte.Length)]; int len = cipher.ProcessBytes(ciphertextbyte, 0, ciphertextbyte.Length, decryptedData, 0); cipher.DoFinal(decryptedData, len); //返回解密字符串 return Encoding.UTF8.GetString(decryptedData); } } } [图片] 以上是我做的整个过程,为何老是报无效签名,签名算法也是用微信提供的,私钥也是转成PCKS8格式,求教!!!
01-06 - 微信同城配送数据签名问题,求教?
由于原项目是使用NET平台C#语言开发,需要对接微信同步配送,微信文档没有提供C#版的数据签名算法,经过多次尝试C#版签名(算法:RSAwithSHA256)一直不正确,于是用微信提供的数据签名的算法,把相关配置换成自己的,并用TOMCAT搭建了个本地WEB服务,给NET提供数据签名服务,为何还是一直报签名不正确? [图片] [图片]
01-04 - 神奇问题,微信开发工具中调用WEB接口返回的数据和直接网页请求和apipos调试工具返回的结果不同?
请求接口:https://samtest.818gifts.com.cn/WeChatApplet/Home.ashx?action=GetFootMenu 1 下面是在微信开发工具发送的HTTP请求返回的结果 [图片] 2下面是网页直接请求的结果: [图片] 3下面APIPOST请求的结果 [图片] 上面结果微信开发工具返回的结果和 网页直接请求,APIPOST请求的结果完全不同,请问微信那边有怎么限制没?还是域名有问题?求解!!!
2023-05-21 - scroll-view组件的drag事件在微信PC版不会触发?
scroll-view组件的binddragstart,binddragend 事件在微信PC版(版本:3.8.1.26)不会触发,开发工具和手机上正常?有人遇到过没?[图片]
2023-01-05 - 小程序开发管理用到getLocation接口,为什么一直申请失败?
问题如标题. 小程序appid:wx691f0cdeff520ae4
2022-10-14 - 开发工具吃内存很厉害,单步调试经常代码定位不准确,变量值也无法显示,如何解决?
有人遇到这样的问题没
2022-09-09