fixed ignore TLS verification for demo setup
This commit is contained in:
parent
908665ddcc
commit
a90f358bd5
2 changed files with 23 additions and 4 deletions
|
@ -122,9 +122,14 @@ public class ClientHttpRequestFactoryService {
|
||||||
log.debug("Initialize ClientHttpRequestFactory with proxy: {}", proxy);
|
log.debug("Initialize ClientHttpRequestFactory with proxy: {}", proxy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final SSLContext sslContext = org.apache.http.ssl.SSLContexts
|
||||||
|
.custom()
|
||||||
|
.loadTrustMaterial(null, new TrustAllStrategy())
|
||||||
|
.build();
|
||||||
|
|
||||||
final HttpComponentsClientHttpRequestFactory factory =
|
final HttpComponentsClientHttpRequestFactory factory =
|
||||||
new HttpComponentsClientHttpRequestFactory();
|
new HttpComponentsClientHttpRequestFactory();
|
||||||
factory.setHttpClient(this.createProxiedClient(proxy, null));
|
factory.setHttpClient(this.createProxiedClient(proxy, sslContext));
|
||||||
factory.setBufferRequestBody(false);
|
factory.setBufferRequestBody(false);
|
||||||
factory.setConnectionRequestTimeout(this.connectionRequestTimeout);
|
factory.setConnectionRequestTimeout(this.connectionRequestTimeout);
|
||||||
factory.setConnectTimeout(this.connectTimeout);
|
factory.setConnectTimeout(this.connectTimeout);
|
||||||
|
@ -133,8 +138,14 @@ public class ClientHttpRequestFactoryService {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
final HttpComponentsClientHttpRequestFactory devClientHttpRequestFactory =
|
final SSLContext sslContext = org.apache.http.ssl.SSLContexts
|
||||||
new HttpComponentsClientHttpRequestFactory();
|
.custom()
|
||||||
|
.loadTrustMaterial(null, new TrustAllStrategy())
|
||||||
|
.build();
|
||||||
|
final HttpClient client = HttpClients.custom()
|
||||||
|
.setSSLContext(sslContext)
|
||||||
|
.build();
|
||||||
|
final HttpComponentsClientHttpRequestFactory devClientHttpRequestFactory = new HttpComponentsClientHttpRequestFactory(client);
|
||||||
|
|
||||||
devClientHttpRequestFactory.setBufferRequestBody(false);
|
devClientHttpRequestFactory.setBufferRequestBody(false);
|
||||||
devClientHttpRequestFactory.setConnectionRequestTimeout(this.connectionRequestTimeout);
|
devClientHttpRequestFactory.setConnectionRequestTimeout(this.connectionRequestTimeout);
|
||||||
|
@ -163,7 +174,7 @@ public class ClientHttpRequestFactoryService {
|
||||||
final String truststoreFilePath = this.environment
|
final String truststoreFilePath = this.environment
|
||||||
.getProperty("server.ssl.trust-store", "");
|
.getProperty("server.ssl.trust-store", "");
|
||||||
|
|
||||||
SSLContext sslContext;
|
final SSLContext sslContext;
|
||||||
if (StringUtils.isBlank(truststoreFilePath)) {
|
if (StringUtils.isBlank(truststoreFilePath)) {
|
||||||
|
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
|
@ -263,6 +274,8 @@ public class ClientHttpRequestFactoryService {
|
||||||
|
|
||||||
if (sslContext != null) {
|
if (sslContext != null) {
|
||||||
clientBuilder.setSSLContext(sslContext);
|
clientBuilder.setSSLContext(sslContext);
|
||||||
|
} else {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return clientBuilder.build();
|
return clientBuilder.build();
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
|
|
||||||
package ch.ethz.seb.sebserver.webservice.servicelayer.lms.impl.moodle;
|
package ch.ethz.seb.sebserver.webservice.servicelayer.lms.impl.moodle;
|
||||||
|
|
||||||
|
import javax.net.ssl.SSLContext;
|
||||||
|
import java.security.cert.X509Certificate;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -21,6 +23,10 @@ import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
|
||||||
|
import org.apache.http.impl.client.CloseableHttpClient;
|
||||||
|
import org.apache.http.impl.client.HttpClients;
|
||||||
|
import org.apache.http.ssl.TrustStrategy;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.http.HttpEntity;
|
import org.springframework.http.HttpEntity;
|
||||||
|
|
Loading…
Reference in a new issue