怎么在best-pay项目中找不到微信或支付宝的商户证书文件

来源:8-2 Service-完成注册功能

网络时空

2020-04-22

师兄,下午好!

对于微信退款或支付宝退款中都涉及到商户证书文件,对于证书文件,但是我怎么找遍了你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);
    }
}
写回答

1回答

网络时空

提问者

2020-04-22

我在best-pay-demo项目的application-dev.yml文件中找到如下配置

wechat:
  mpAppId: wxd898xxxx
  mchId: 1483xxxx
  mchKey: C5245D70xxxxx
  keyPath: /var/weixin_cert/wxpay.p12
  notifyUrl: http://xxx.com/notify
  miniAppId: wxxxxxxxxxxx6bf9b
  miniAppSecret: xxbc6xxxxxxxxxxxxxx9c49d
  appAppId: wxxxxxxxxxxxx43b0


但是这个路径是在 /var/weixin_cert/wxpay.p12, 这个应该是在师兄对应的linux环境的目录下面,我现在在windowns环境没有这个证书文件,就测试不了退款流程啊!



0
7
网络时空
回复
慕仔4607872
在如下URL https://git.imooc.com/coding-392/?location=https%3A%2F%2Fgit.imooc.com%2Fcoding-392%2F 你如果购买了课程就可以看到啊
2021-02-12
共7条回复

实战支付+电商双系统 玩转Java技术栈

花一份课的价,收获:双系统实战+坐拥20K+粉的师兄指导,值~

2046 学习 · 1048 问题

查看课程