师兄,下午好!
对于微信退款或支付宝退款中都涉及到商户证书文件,对于证书文件,但是我怎么找遍了你sdk的best-pay项目,都没有找到对应的商户证证书文件,请问商户证书你是放在哪个目录下面呢? 请告知下,谢谢!
/**
* 商户证书路径
*/
private String keyPath;
/**
* 证书内容
*/
private SSLContext sslContext;
/**
* 初始化证书
* @return
*/
public SSLContext initSSLContext() {
FileInputStream inputStream = null;
try {
inputStream = new FileInputStream(new File(this.keyPath));
} catch (IOException e) {
throw new RuntimeException("读取微信商户证书文件出错", e);
}
try {
KeyStore keystore = KeyStore.getInstance("PKCS12");
char[] partnerId2charArray = mchId.toCharArray();
keystore.load(inputStream, partnerId2charArray);
this.sslContext = SSLContexts.custom().loadKeyMaterial(keystore, partnerId2charArray).build();
return this.sslContext;
} catch (Exception e) {
throw new RuntimeException("证书文件有问题,请核实!", e);
} finally {
IOUtils.closeQuietly(inputStream);
}
}