Commit 87f50b15 authored by 郑建's avatar 郑建

增加删除临时文件

parent b406378d
......@@ -106,6 +106,8 @@ public class HttpClientConfig {
@Bean("niwodaiHttpsClient")
public CloseableHttpClient niwodaiHttpsClient() throws Exception{
File temp1 = null,temp2 = null;
try{
/**
* 创建TrustManager
*/
......@@ -125,9 +127,11 @@ public class HttpClientConfig {
};
String classesPath = "/niwodai";
KeyStore keyStore = KeyStore.getInstance("PKCS12");
keyStore.load(new FileInputStream(asFile(readJarFile(classesPath + "/qg-keystore.jks"))), "password".toCharArray());
temp1 = asFile(readJarFile(classesPath + "/qg-keystore.jks"));
keyStore.load(new FileInputStream(temp1), "password".toCharArray());
temp2 = asFile(readJarFile(classesPath + "/qg-truststore.jks"));
SSLContext sslcontext = SSLContexts.custom()
.loadTrustMaterial(asFile(readJarFile(classesPath + "/qg-truststore.jks")), "password".toCharArray(), new TrustSelfSignedStrategy())
.loadTrustMaterial(temp2, "password".toCharArray(), new TrustSelfSignedStrategy())
.loadKeyMaterial(keyStore, "password".toCharArray())
.build();
SSLConnectionSocketFactory sslConnectionSocketFactory = new SSLConnectionSocketFactory(
......@@ -166,6 +170,15 @@ public class HttpClientConfig {
.setRetryHandler(retryHandler)
.setKeepAliveStrategy(keepAliveStrategy)
.build();
}finally {
if (temp1 != null){
temp1.delete();
}
if (temp2 != null){
temp2.delete();
}
}
}
private static InputStream readJarFile(String fileName) throws IOException
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment