Commit ebdee75f authored by 郑建's avatar 郑建

线上配置

parent 74494e41
......@@ -18,6 +18,7 @@ import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.protocol.HttpContext;
import org.apache.http.ssl.SSLContexts;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.ClassUtils;
......@@ -41,6 +42,9 @@ import java.security.cert.X509Certificate;
@Configuration
public class HttpClientConfig {
@Value("${niwodai.online}")
private Boolean isOnLine;
@Bean(name = "httpClient")
public CloseableHttpClient httpClient() throws NoSuchAlgorithmException, KeyManagementException {
/**
......@@ -124,10 +128,10 @@ public class HttpClientConfig {
}
};
String classesPath = "/niwodai";
KeyStore keyStore = KeyStore.getInstance("PKCS12");
keyStore.load(HttpClientConfig.class.getResourceAsStream(classesPath + "/qg-keystore.jks"), "password".toCharArray());
KeyStore keyStore = KeyStore.getInstance("JKS");
keyStore.load(HttpClientConfig.class.getResourceAsStream(classesPath + "/qg-keystore" + (isOnLine?"":"-test") +".jks"), "password".toCharArray());
KeyStore trustStore = KeyStore.getInstance("JKS");
trustStore.load(HttpClientConfig.class.getResourceAsStream(classesPath + "/qg-truststore.jks"), "password".toCharArray());
trustStore.load(HttpClientConfig.class.getResourceAsStream(classesPath + "/qg-truststore" + (isOnLine?"":"-test") +".jks"), "password".toCharArray());
SSLContext sslcontext = SSLContexts.custom()
.loadTrustMaterial(trustStore, new TrustSelfSignedStrategy())
.loadKeyMaterial(keyStore, "password".toCharArray())
......
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