1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package com.dy.pipIrrGlobal.cert;
 
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import java.io.InputStream;
 
/**
 * @Author: liurunyu
 * @Date: 2024/8/19 19:58
 * @Description
 */
public class WxCertUtil {
 
    public static final String cert_p12 = "classpath:wxCert/apiclient_cert.p12" ;//证书pkcs12格式
    public static final String cert_pem = "classpath:wxCert/apiclient_cert.pem" ;//证书pem格式
    public static final String key_pem = "classpath:wxCert/apiclient_key.pem" ;//证书密钥pem格式
    public static final String wxp_cert_pem = "classpath:wxCert/wxp_cert.pem" ;
 
    public static InputStream getCert_p12InputStream(ResourceLoader resourceLoader) throws Exception{
        Resource resource = resourceLoader.getResource(cert_p12);
        InputStream in = resource.getInputStream() ;
        return in ;
    }
 
    public static byte[] getKey_pemBytes(ResourceLoader resourceLoader) throws Exception{
        Resource resource = resourceLoader.getResource(key_pem);
        InputStream in = resource.getInputStream() ;
        byte[] bs = new byte[in.available()] ;
        return bs ;
    }
 
}