Skip to content

从base64字符串加载密钥时报错 #3765

Closed

Description

@wangzhengzhen

版本:4.7.8.B

在构建WxPayConfig配置时,如果设置base64密钥串,读取时会出现base64解码异常。定位源码,发现问题出在WxPayConfig中的方法:

Image Image

调用this.loadConfigInputStream 获取 inputStream,再执行 merchantPrivateKey = PemUtils.loadPrivateKey(keyInputStream);

Image

在 PemUtils.loadPrivateKey 对流再次进行base64解码

Activity

  1. wangzhengzhen commented on Nov 26, 2025

    @wangzhengzhen
    Author

    呃,那可能是我错误理解这个设置String方法。我在set密钥时,就已经是base64格式了(密钥自己读取p12文件转换的)。一般不会有人直接把已经是base64的证书再base64来保存吧。setPath是证书,setString理解的是base64编码的密钥串,而不是base64编码的证书

  2. added a commit that references this issue on Nov 27, 2025
  3. added a commit that references this issue on Dec 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions