| | |
| | | */ |
| | | private String privateKeyPath; |
| | | /** |
| | | * 微信支付公钥id |
| | | */ |
| | | private String publicKeyId; |
| | | /** |
| | | * 微信支付公钥证书 apiclient_cert.pem |
| | | */ |
| | | private String publicKeyPath; |
| | | /** |
| | | * 商户证书序列号 |
| | | */ |
| | | private String mchSerialNo; |
| | |
| | | } |
| | | 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); |
| | | } |
| | | } |