Self assigned SSL certificate for Solr

in #sitecore7 years ago

All you developers who are struggling your way to install Sitecore 9 with Solr and SSL for SOLR

Kamsar created a script for this, Kudos to him!

Here is the link to it - https://gist.github.com/kamsar/c3c8322c1ec40eac64c7dd546e5124de#file-anexample-ps1

This script will create Self signed SSL certificate for your local solr instance - http://localhost:8983

I got this error when I run it.

PS C:\solr-6.6.1> .\solrssl.ps1 -KeystoreFile C:\solr-6.6.1\server\etc\solr-ssl.keystore.jks -Clobber
keytool.exe not on path. Enter path to keytool (found in JRE bin folder): C:\Program Files\Java\jdk-9.0.4\bin\keytool.exe

Generating JKS keystore...

Generating .p12 to import to Windows...
keytool.exe : Importing keystore C:\solr-6.6.1\server\etc\solr-ssl.keystore.jks to C:\solr-6.6.1\server\etc\solr-ssl.keystore.p12...
At C:\solr-6.6.1\solrssl.ps1:54 char:1

  • & $keytool -importkeystore -srckeystore $KeystoreFile -destkeystore $ ...
  •   + CategoryInfo          : NotSpecified: (Importing keyst...keystore.p12...:String) [], RemoteException
      + FullyQualifiedErrorId : NativeCommandError
    
    
    

I solved this error by adding by adding "C:\Program Files\Java\jdk-9.0.4\bin" to the environment variable to the PATH:

After doing that open your PowerShell as administrator and re-run .ps1 file as below:

.\solrssl.ps1 -KeystoreFile C:\solr-6.6.1\server\etc\solr-ssl.keystore.jks

you will see something like below and follow the NEXT Steps:

  1. Copy your keystore to $SOLR_HOME\server\etc (MUST be here)

  2. Add the following lines to your solr.in.cmd:

set SOLR_SSL_KEY_STORE=etc/solr-ssl.keystore.jks
set SOLR_SSL_KEY_STORE_PASSWORD=secret
set SOLR_SSL_TRUST_STORE=etc/solr-ssl.keystore.jks
set SOLR_SSL_TRUST_STORE_PASSWORD=secret

Stop your Solr : solr stop -all

Restart your Solr : solr start

Go back to your https://localhost:8983 and it should work on https:

Let me know if you find any issues.

Happy coding