-
微信证书存储方式
1.通过inputStream直接加载证书流(需要放到项目某一位置)
为了避免windows和linux区别直接用
SpringBootApplication.Class.getResourceAsStream("/apiclient_cert.p12")
获取文件流传入需要携带证书请求方式中进行微信服务器交互
/**
* 需要证书
*
* @param
* @return XML字符串
* @throws Exception
*/
public static String doWxpayRequest(String httpurl, String strxml, String mch_id, InputStream in) throws Exception {
CloseableHttpClient client = null;
HttpPost httpPost = null;
try {
KeyStore clientTrustKeyStore = KeyStore.getInstance("PKCS12");
clientTrustKeyStore.load(in, mch_id.toCharArray());
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
kmf.init(clientTrustKeyStore, mch_id.toCharArray());