liujie
1 天以前 718ded0f5f8dd6f1da43b9de2ff20ddc12714007
ruoyi-system/src/main/java/com/ruoyi/system/wxPay/model/V3.java
@@ -28,6 +28,14 @@
     */
    private String privateKeyPath;
    /**
     * 微信支付公钥id
     */
    private String publicKeyId;
    /**
     * 微信支付公钥证书 apiclient_cert.pem
     */
    private String publicKeyPath;
    /**
     * 商户证书序列号
     */
    private String  mchSerialNo;
@@ -74,4 +82,27 @@
        }
        return new ByteArrayInputStream(certData);
    }
    public InputStream getPublicKeyStream() {
        // 需要证书释放
        byte[] certData;
//        InputStream certStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(this.privateKeyPath);
        InputStream certStream = null;
        try {
            certStream = new FileInputStream(this.publicKeyPath);
            certData = IOUtils.toByteArray(certStream);
        } catch (IOException e) {
            e.printStackTrace();
            throw new RuntimeException("公钥文件未找到");
        }finally {
            if(null != certStream){
                try {
                    certStream.close();
                } catch (IOException e) {
                    log.error("公钥流关闭异常");
                }
            }
        }
        return new ByteArrayInputStream(certData);
    }
}