JAVA读取pem私钥文件可以使用com.wechat.pay.contrib.apache.httpclient.util.PemUtil包下的方法,或者hutool-crypto包下方法
<!--微信支付API-->
<dependency>
<groupId>com.github.wechatpay-apiv3</groupId>
<artifactId>wechatpay-apache-httpclient</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/cn.hutool/hutool-crypto -->
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-crypto</artifactId>
<version>5.6.1</version>
</dependency>
privateKey = PemUtil.loadPrivateKey(new FileInputStream("src/main/resources/privatekey/key.pem")