Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

为什么私钥路径一定要是绝对路径,多个项目成员如何管理这个路径 #271

Open
wanglong1615 opened this issue May 6, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@wanglong1615
Copy link

错误描述

PemUtil.loadPrivateKey好歹接受一个文件流啊

重现bug的步骤

为什么私钥路径一定要是绝对路径,多个项目成员如何管理这个路径

预期行为

为什么私钥路径一定要是绝对路径,多个项目成员如何管理这个路径

导致错误的代码片段

PemUtil.loadPrivateKey好歹接受个文件流啊

操作系统

Linux

Java 版本

JAVA 8

wechatpay-java 版本

0.2.12

其他信息

为什么私钥路径一定要是绝对路径,多个项目成员如何管理这个路径

@wanglong1615 wanglong1615 added the bug Something isn't working label May 6, 2024
@lvguangzeng
Copy link

lvguangzeng commented Jun 13, 2024

        ClassPathResource classPathResource = new ClassPathResource("privateKeyPath");
        String privateKeyString = new BufferedReader(new InputStreamReader(classPathResource.getInputStream()))
                .lines().collect(Collectors.joining(System.lineSeparator()));
        PrivateKey privateKey = PemUtil.loadPrivateKeyFromString(privateKeyString);
        
        RSAAutoCertificateConfig config = new RSAAutoCertificateConfig.Builder()
                .merchantId(merchantId)
                .privateKey(privateKey)
                .merchantSerialNumber(merchantSerialNumber)
                .apiV3Key(apiV3Key)
                .build();

我用Spring的ClassPathResource读取的文件流。感觉微信支付写SDK或者设计接口的都不会用自己做出来的东西……🍐🎼

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants