Created
April 21, 2020 16:21
-
-
Save ravibharathii/b5b2d772a6621da4c28f2880732a5097 to your computer and use it in GitHub Desktop.
Suppress Domain Name mismatch SSL error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final SSLConnectionSocketFactory sslsf; | |
try { | |
sslsf = new SSLConnectionSocketFactory(SSLContext.getDefault(), | |
NoopHostnameVerifier.INSTANCE); | |
} catch (NoSuchAlgorithmException e) { | |
throw new RuntimeException(e); | |
} | |
final Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create() | |
.register("http", new PlainConnectionSocketFactory()) | |
.register("https", sslsf) | |
.build(); | |
final PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager(registry); | |
cm.setMaxTotal(100); | |
HttpClient httpClient = HttpClients.custom() | |
.setSSLSocketFactory(sslsf) | |
.setConnectionManager(cm) | |
.build(); | |
// new HttpSolrClient.Builder().withHttpClient(httpClient).withBaseSolrUrl(solrHost); | |
final CloudSolrClient client ; | |
CloudSolrClient.Builder builder = new CloudSolrClient.Builder(); | |
if (httpClient != null) { | |
builder = builder.withHttpClient(httpClient); | |
} | |
builder.withSolrUrl(solrHost); | |
client = builder.build(); | |
client.setDefaultCollection(collection) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment