Using SolrJ with BASIC authentication and SSL wrapped Solr

Eric PughSeptember 24, 2013

Do you have BASIC authentication turned on for Solr? Are you using a self signed SSL Certificate? Do you want to index to this server using SolrJ? I’ve taken a couple of tries to get all the magic incantations to work, but finally have done it. Hopefully this saves you some of the pain I experienced in searching around StackOverflow and random blog posts.

Some of the error messages you might get are javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated or unauthorized access.

To sum it up, you have to fake out the certificate checking and then wrap your http call with something called Preemptive Authentication.

Here is the method, you can get it here.

To use this class just pass in your regular client and username/password combo:

By the way, the equivalent of all of this in curl is:

curl --user admin:password --insecure "https://localhost:443/solr/update/?commit=true"




More blog articles:


Let's do a project together!

We provide tailored search, discovery and analytics solutions using Solr and Elasticsearch. Learn more about our service offerings