Commit ad08fb3a authored by liwenbin's avatar liwenbin

f

parent fee8f209
...@@ -42,8 +42,8 @@ import java.security.cert.X509Certificate; ...@@ -42,8 +42,8 @@ import java.security.cert.X509Certificate;
@Configuration @Configuration
public class HttpClientConfig { public class HttpClientConfig {
@Value("${niwodai.online}") @Value("${isDebug}")
private Boolean isOnLine; private Boolean isDebug;
@Bean(name = "httpClient") @Bean(name = "httpClient")
public CloseableHttpClient httpClient() throws NoSuchAlgorithmException, KeyManagementException { public CloseableHttpClient httpClient() throws NoSuchAlgorithmException, KeyManagementException {
...@@ -129,9 +129,9 @@ public class HttpClientConfig { ...@@ -129,9 +129,9 @@ public class HttpClientConfig {
}; };
String classesPath = "/niwodai"; String classesPath = "/niwodai";
KeyStore keyStore = KeyStore.getInstance("JKS"); KeyStore keyStore = KeyStore.getInstance("JKS");
keyStore.load(HttpClientConfig.class.getResourceAsStream(classesPath + "/qg-keystore" + (isOnLine?"":"-test") +".jks"), "password".toCharArray()); keyStore.load(HttpClientConfig.class.getResourceAsStream(classesPath + "/qg-keystore" + (isDebug ? "-test" : "") +".jks"), "password".toCharArray());
KeyStore trustStore = KeyStore.getInstance("JKS"); KeyStore trustStore = KeyStore.getInstance("JKS");
trustStore.load(HttpClientConfig.class.getResourceAsStream(classesPath + "/qg-truststore" + (isOnLine?"":"-test") +".jks"), "password".toCharArray()); trustStore.load(HttpClientConfig.class.getResourceAsStream(classesPath + "/qg-truststore" + (isDebug ? "-test" : "") +".jks"), "password".toCharArray());
SSLContext sslcontext = SSLContexts.custom() SSLContext sslcontext = SSLContexts.custom()
.loadTrustMaterial(trustStore, new TrustSelfSignedStrategy()) .loadTrustMaterial(trustStore, new TrustSelfSignedStrategy())
.loadKeyMaterial(keyStore, "password".toCharArray()) .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