New file |
| | |
| | | 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()] ; |
| | | in.read(bs) ; |
| | | return bs ; |
| | | } |
| | | |
| | | } |