版本:4.7.8.B 在构建WxPayConfig配置时,如果设置base64密钥串,读取时会出现base64解码异常。定位源码,发现问题出在WxPayConfig中的方法: <img width="931" height="367" alt="Image" src="https://github.com/user-attachments/assets/6408e2f4-d42f-451d-8a40-52e99ddd74d8" /> <img width="1116" height="227" alt="Image" src="https://github.com/user-attachments/assets/facd6c19-110a-4d27-abaa-f308ce645372" /> 调用this.loadConfigInputStream 获取 inputStream,再执行 merchantPrivateKey = PemUtils.loadPrivateKey(keyInputStream); <img width="760" height="574" alt="Image" src="https://github.com/user-attachments/assets/c3b056ce-cb27-4648-aa4f-d97b01728998" /> 在 PemUtils.loadPrivateKey 对流再次进行base64解码
Activity
wangzhengzhen commentedon Nov 26, 2025
呃,那可能是我错误理解这个设置String方法。我在set密钥时,就已经是base64格式了(密钥自己读取p12文件转换的)。一般不会有人直接把已经是base64的证书再base64来保存吧。setPath是证书,setString理解的是base64编码的密钥串,而不是base64编码的证书
🎨 #3765 【微信支付】修复从 base64 字符串加载私钥时的双重解码问题
🎨 #3765 【微信支付】修复从 base64 字符串加载私钥时的双重解码问题