Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Commit 0eab0f1

Browse files
committed
fixed #194
1 parent 6f05f63 commit 0eab0f1

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/main/java/com/marklogic/rest/util/RestTemplateUtil.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
import org.apache.http.client.HttpClient;
66
import org.apache.http.conn.ssl.SSLContextBuilder;
77
import org.apache.http.conn.ssl.TrustStrategy;
8+
import org.apache.http.conn.ssl.X509HostnameVerifier;
89
import org.apache.http.impl.client.BasicCredentialsProvider;
910
import org.apache.http.impl.client.HttpClientBuilder;
1011
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
1112
import org.springframework.web.client.RestTemplate;
1213

13-
import javax.net.ssl.SSLContext;
14+
import javax.net.ssl.*;
15+
import java.io.IOException;
1416
import java.security.cert.CertificateException;
1517
import java.security.cert.X509Certificate;
1618

@@ -50,6 +52,21 @@ public boolean isTrusted(X509Certificate[] chain, String authType) throws Certif
5052
}
5153
}).build();
5254
httpClientBuilder.setSslcontext(sslContext);
55+
httpClientBuilder.setHostnameVerifier(new X509HostnameVerifier() {
56+
@Override
57+
public void verify(String host, SSLSocket ssl) throws IOException {}
58+
59+
@Override
60+
public void verify(String host, X509Certificate cert) throws SSLException {}
61+
62+
@Override
63+
public void verify(String host, String[] cns, String[] subjectAlts) throws SSLException {}
64+
65+
@Override
66+
public boolean verify(String s, SSLSession sslSession) {
67+
return false;
68+
}
69+
});
5370
} catch (Exception ex) {
5471
throw new RuntimeException("Unable to configure simple SSL approach: " + ex.getMessage(), ex);
5572
}

0 commit comments

Comments
 (0)