Skip to content

Commit 13f9c64

Browse files
authored
🎨 初始化v3客户端时,未设置证书序列号值才尝试加载证书
1 parent 7bbe805 commit 13f9c64

File tree

1 file changed

+5
-3
lines changed
  • weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config

1 file changed

+5
-3
lines changed

weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config/WxPayConfig.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,12 +262,12 @@ public CloseableHttpClient initApiV3HttpClient() throws WxPayException {
262262

263263
InputStream keyInputStream = this.loadConfigInputStream(this.getPrivateKeyString(), this.getPrivateKeyPath(),
264264
this.privateKeyContent, "privateKeyPath");
265-
InputStream certInputStream = this.loadConfigInputStream(this.getPrivateCertString(), this.getPrivateCertPath(),
266-
this.privateCertContent, "privateCertPath");
267265
try {
268266
PrivateKey merchantPrivateKey = PemUtils.loadPrivateKey(keyInputStream);
269-
X509Certificate certificate = PemUtils.loadCertificate(certInputStream);
270267
if (StringUtils.isBlank(this.getCertSerialNo())) {
268+
InputStream certInputStream = this.loadConfigInputStream(this.getPrivateCertString(), this.getPrivateCertPath(),
269+
this.privateCertContent, "privateCertPath");
270+
X509Certificate certificate = PemUtils.loadCertificate(certInputStream);
271271
this.certSerialNo = certificate.getSerialNumber().toString(16).toUpperCase();
272272
}
273273
//构造Http Proxy正向代理
@@ -290,6 +290,8 @@ public CloseableHttpClient initApiV3HttpClient() throws WxPayException {
290290
this.privateKey = merchantPrivateKey;
291291

292292
return httpClient;
293+
} catch (WxPayException e) {
294+
throw e;
293295
} catch (Exception e) {
294296
throw new WxPayException("v3请求构造异常!", e);
295297
}

0 commit comments

Comments
 (0)