New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Init NewClient Error #135
Comments
看提示是下载微信支付平台证书时失败了。 mchAPIv3Key 是对的吗?用这个密钥能成功下载证书吗? 你试试用 证书下载工具 下载证书。 |
使用这个工具通过jar包下载,返回 |
有两个证书,看看是不是弄混了。 |
今天重新试了一下
补充一下: 根据这个文档里的验签说明,使用 代码片段 var (
mchID string = "11111111" // 商户号
mchCertificateSerialNumber string = "11111111111111" // 商户证书序列号
mchAPIv3Key string = "okadfdsfsdfsf**********" // 商户APIv3密钥
)
// 使用 utils 提供的函数从本地文件中加载商户私钥,商户私钥会用来生成请求的签名
mchPrivateKey, err := utils.LoadPrivateKeyWithPath("/path/to/apiclient_key.pem")
if err != nil {
log.Print("load merchant private key error")
}
fmt.Println(mchPrivateKey)
fmt.Println(mchID)
fmt.Println(mchCertificateSerialNumber)
fmt.Println(mchAPIv3Key)
ctx := context.Background()
// 使用商户私钥等初始化 client,并使它具有自动定时获取微信支付平台证书的能力
opts := []core.ClientOption{
option.WithWechatPayAutoAuthCipher(mchID, mchCertificateSerialNumber, mchPrivateKey, mchAPIv3Key),
}
fmt.Println(opts)
client, err := core.NewClient(ctx, opts...)
if err != nil {
log.Printf("new wechat pay client err:%s", err)
}
svc := jsapi.JsapiApiService{Client: client} 报错是在 |
你检查下你的 APIv3Key 是否正确? 从微信支付平台证书下载接口获取到的证书使用了 APIv3Key 做了 AES_GCM 加密。如果 APIv3Key 不正确,会导致 |
APIV3Key是正确的,在证书下,有v2和v3,这个检查了一下,就是v3key,应该不会出错 |
初始化的过程,会使用 APIv3Key 解密微信支付平台证书。
你可以试试能否解密微信支付平台证书下载得到的 ciphertext。可以找一些 AES-GCM 在线解密的服务,也可以用 utils/aes 试试。 |
是这里配置。如果不影响现网业务,可以试着重置一次试试。 |
可以了,重置一下 |
bug
按照示例代码进行测试,商户号,秘钥等都是按照文档操作通过服务商后台进行配置,证书为下载好通过本地读取文件方式进行加载压缩包中提供好的
apiclient_key.pem
文件报错:decrypt downloaded certificate failed: cipher: message authentication failed.
1.17.3
wechatpay-apiv3/wechatpay-go@v0.2.16
The text was updated successfully, but these errors were encountered: