Using SolrJ with BASIC authentication and SSL wrapped Solr

Eric Pugh — September 24, 2013 | 0 Comments | Filed in: Java, solr Tagged: , , , , |

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"

Eric Pugh

Fascinated by the “craft” of software development, Eric Pugh has been heavily involved in the open source world as a developer, committer, and user. He is co-author of the book Apache Solr 3 Enterprise Search Server.

Contact Eric

Developed in Charlottesville, VA | ©2013 – OpenSource Connections, LLC