sam
sam

Reputation: 63

IOException when attempting to connect to Solr using HTTPS

Connecting to a Solr server using a http request was straightforward. But when I try to connect using a https request, I am getting errors.

Solr server: https://localhost:8443/solr/#/

I tried using solr api in java to connect to server with following code:

SolrServer server = new HttpSolrServer("https://localhost:8443/solr/#/");

But I got the following exceptions:

Exception in thread "main" org.apache.solr.client.solrj.SolrServerException: IOException occured when talking to server at: https://localhost:8443/solr/#
at org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:413)
at org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:181)
at org.apache.solr.client.solrj.request.QueryRequest.process(QueryRequest.java:90)
at org.apache.solr.client.solrj.SolrServer.query(SolrServer.java:301)
at app.SolrQuerying.main(SolrQuerying.java:45)
Caused by: javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated
at com.sun.net.ssl.internal.ssl.SSLSessionImpl.getPeerCertificates(SSLSessionImpl.java:352)
at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:128)
at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:397)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:148)
at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:150)
at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:121)
at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:575)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:425)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:754)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:732)
at org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:352)
... 4 more

If anyone has any solution to this, please share.

Upvotes: 2

Views: 5829

Answers (1)

Matt Clark
Matt Clark

Reputation: 28599

You error is show in the log here:

Caused by: javax.net.ssl.SSLPeerUnverifiedException

What this is saying is that your SSL Certificate is not verified by a Certificate Authority, I am guessing you created a self signed certificate? Java by default will check for certificates that are verified by a Certificate Authority and error if not. The reason for this is security.

Look up how to use self-signed certificates with a Java Connection.

Upvotes: 1

Related Questions