0

I am trying to install Sitecore 9 (Update 1) through SIF. I have everything in place, I just need to enable SSL for Solr. I have Solr 6.6.2. I saw the official reference and have no idea how to install OpenSSL nor add it to my PATH variable (not to mention that the link is broken and I can't find the binaries). Then I found a workaround, or at least so it seemed. I've run this script (see workaround link) and have entered the path to the keytool.exe but I get this every time:

Generating .p12 to import to Windows...
keytool.exe : Entry for alias solr-ssl successfully imported.

That shows up in red, which makes no sense because it doesn't sound like an error. It sounds like something worked. I should mention that I didn't run the following line:

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

because every time I do, I get:

.\solrssl.ps1 : The term '.\solrssl.ps1' is not recognized as the name of a cmdlet, function, 
script file, or operable program. Check the spelling of the name, or if a path was included, verify 
that the path is correct and try again.
  • 2
    Just found out I have SQL Server 2012. Thought I had 2016 but I just had the SSMS 2016. Going to install 2016 server now and retry sim.. – Paul May 2 '18 at 15:12
  • Updated my 2012 instance to 2016 and the SIM tool created a new Sitecore 9 instance successfully. That being said, should I post this as an answer? I still want to find out how to set up SSL for Solr so I can do this the SIF way. – Paul May 2 '18 at 15:45
  • If you're still having issues related to SOLR install now that you've sorted the SQL install, I suggest you update your question to reflect these specific issues and we let it run – Mark Cassidy May 2 '18 at 17:52
  • Please take look on my step by step guide how to install and configure SSL on Solr 6.6.2 for Sitecore 9 -> tothecore.sk/2018/02/05/… – Peter Procházka May 2 '18 at 18:36
  • It will also show you how to set Solr as Windows Service – Peter Procházka May 2 '18 at 18:39
2

You will require to download the followings:

  • Java SE Runtime Environment 9.0.1
  • NSSM 2.24
  • Solr 6.6.2

Download all and install the JRE 9.0.1 at default location Extract all the contents of the SOLR and NSSM in the directory

C:\solr

Now run the save the following as the PowerShell and run it, it will do the rest installation for Solr 6.6.2.

Param(
    $solrVersion = "6.6.2",
    $installFolder = "c:\solr",
    $solrPort = "8983",
    $solrHost = "solr",
    $solrSSL = $true,
    $nssmVersion = "2.24",
    $JREVersion = "9.0.1"
)

$JREPath = "C:\Program Files\Java\jre-$JREVersion"
$solrName = "solr-$solrVersion"
$solrRoot = "$installFolder\$solrName"
$nssmRoot = "$installFolder\nssm-$nssmVersion"
$solrPackage = "https://archive.apache.org/dist/lucene/solr/$solrVersion/$solrName.zip"
$nssmPackage = "https://nssm.cc/release/nssm-$nssmVersion.zip"
$downloadFolder = "~\Downloads"

## Verify elevated
## https://superuser.com/questions/749243/detect-if-powershell-is-running-as-administrator
$elevated = [bool](([System.Security.Principal.WindowsIdentity]::GetCurrent()).groups -match "S-1-5-32-544")
if($elevated -eq $false)
{
    throw "In order to install services, please run this script elevated."
}

function downloadAndUnzipIfRequired
{
    Param(
        [string]$toolName,
        [string]$toolFolder,
        [string]$toolZip,
        [string]$toolSourceFile,
        [string]$installRoot
    )

    if(!(Test-Path -Path $toolFolder))
    {
        if(!(Test-Path -Path $toolZip))
        {
            Write-Host "Downloading $toolName..."
            Start-BitsTransfer -Source $toolSourceFile -Destination $toolZip
        }

        Write-Host "Extracting $toolName to $toolFolder..."
        Expand-Archive $toolZip -DestinationPath $installRoot
    }
}
# download & extract the solr archive to the right folder
$solrZip = "$downloadFolder\$solrName.zip"
downloadAndUnzipIfRequired "Solr" $solrRoot $solrZip $solrPackage $installFolder

# download & extract the nssm archive to the right folder
$nssmZip = "$downloadFolder\nssm-$nssmVersion.zip"
downloadAndUnzipIfRequired "NSSM" $nssmRoot $nssmZip $nssmPackage $installFolder

# Ensure Java environment variable
$jreVal = [Environment]::GetEnvironmentVariable("JAVA_HOME", [EnvironmentVariableTarget]::Machine)
if($jreVal -ne $JREPath)
{
    Write-Host "Setting JAVA_HOME environment variable"
    [Environment]::SetEnvironmentVariable("JAVA_HOME", $JREPath, [EnvironmentVariableTarget]::Machine)
}

# if we're using HTTP
if($solrSSL -eq $false)
{
    # Update solr cfg to use right host name
    if(!(Test-Path -Path "$solrRoot\bin\solr.in.cmd.old"))
    {
        Write-Host "Rewriting solr config"

        $cfg = Get-Content "$solrRoot\bin\solr.in.cmd"
        Rename-Item "$solrRoot\bin\solr.in.cmd" "$solrRoot\bin\solr.in.cmd.old"
        $newCfg = $newCfg | % { $_ -replace "REM set SOLR_HOST=192.168.1.1", "set SOLR_HOST=$solrHost" }
        $newCfg | Set-Content "$solrRoot\bin\solr.in.cmd"
    }
}

# Ensure the solr host name is in your hosts file
if($solrHost -ne "localhost")
{
    $hostFileName = "c:\\windows\system32\drivers\etc\hosts"
    $hostFile = [System.Io.File]::ReadAllText($hostFileName)
    if(!($hostFile -like "*$solrHost*"))
    {
        Write-Host "Updating host file"
        "`r`n127.0.0.1`t$solrHost" | Add-Content $hostFileName
    }
}

# if we're using HTTPS
if($solrSSL -eq $true)
{
    # Generate SSL cert
    $existingCert = Get-ChildItem Cert:\LocalMachine\Root | where Subject -eq "CN=$solrHost"
    if(!($existingCert))
    {
        Write-Host "Creating & trusting an new SSL Cert for $solrHost"

        # Generate a cert
        # https://docs.microsoft.com/en-us/powershell/module/pkiclient/new-selfsignedcertificate?view=win10-ps

        # $cert = New-SelfSignedCertificate -DnsName www.fabrikam.com, www.contoso.com -CertStoreLocation "cert:\LocalMachine" 

        #working
        $cert = New-SelfSignedCertificate -DnsName "$solrHost" -CertStoreLocation cert:\LocalMachine\My

        # Trust the cert
        # https://stackoverflow.com/questions/8815145/how-to-trust-a-certificate-in-windows-powershell
        $store = New-Object System.Security.Cryptography.X509Certificates.X509Store "Root","LocalMachine"
        $store.Open("ReadWrite")
        $store.Add($cert)
        $store.Close()

        # remove the untrusted copy of the cert
        $cert | Remove-Item
    }

    # export the cert to pfx using solr's default password
    if(!(Test-Path -Path "$solrRoot\server\etc\solr-ssl.keystore.pfx"))
    {
        Write-Host "Exporting cert for Solr to use"

        $cert = Get-ChildItem Cert:\LocalMachine\Root | where Subject -eq "CN=$solrHost"

        $certStore = "$solrRoot\server\etc\solr-ssl.keystore.pfx"
        $certPwd = ConvertTo-SecureString -String "secret" -Force -AsPlainText
        $cert | Export-PfxCertificate -FilePath $certStore -Password $certpwd | Out-Null
    }

    # Update solr cfg to use keystore & right host name
    if(!(Test-Path -Path "$solrRoot\bin\solr.in.cmd.old"))
    {
        Write-Host "Rewriting solr config"

        $cfg = Get-Content "$solrRoot\bin\solr.in.cmd"
        Rename-Item "$solrRoot\bin\solr.in.cmd" "$solrRoot\bin\solr.in.cmd.old"
        $newCfg = $cfg | % { $_ -replace "REM set SOLR_SSL_KEY_STORE=etc/solr-ssl.keystore.jks", "set SOLR_SSL_KEY_STORE=$certStore" }
        $newCfg = $newCfg | % { $_ -replace "REM set SOLR_SSL_KEY_STORE_PASSWORD=secret", "set SOLR_SSL_KEY_STORE_PASSWORD=secret" }
        $newCfg = $newCfg | % { $_ -replace "REM set SOLR_SSL_TRUST_STORE=etc/solr-ssl.keystore.jks", "set SOLR_SSL_TRUST_STORE=$certStore" }
        $newCfg = $newCfg | % { $_ -replace "REM set SOLR_SSL_TRUST_STORE_PASSWORD=secret", "set SOLR_SSL_TRUST_STORE_PASSWORD=secret" }
        $newCfg = $newCfg | % { $_ -replace "REM set SOLR_HOST=192.168.1.1", "set SOLR_HOST=$solrHost" }
        $newCfg | Set-Content "$solrRoot\bin\solr.in.cmd"
    }
}
# install the service & runs
$svc = Get-Service "$solrName" -ErrorAction SilentlyContinue
if(!($svc))
{
    Write-Host "Installing Solr service"
    &"$installFolder\nssm-$nssmVersion\win32\nssm.exe" install "$solrName" "$solrRoot\bin\solr.cmd" "-f" "-p $solrPort"
    $svc = Get-Service "$solrName" -ErrorAction SilentlyContinue
}
if($svc.Status -ne "Running")
{
    Write-Host "Starting Solr service"
    Start-Service "$solrName"
}

# finally prove it's all working
$protocol = "http"
if($solrSSL -eq $true)
{
    $protocol = "https"
}
Invoke-Expression "start $($protocol)://$($solrHost):$solrPort/solr/#/"

This script is from @jermdavis

You can see my complete guide for Sitecore 9 installation here as well.

1

To add SSL to Solr,We need to generate the ssl key by using java keyttol.exe which is in location ‘C:\Program Files\solr-6.6.2\server\etc’.Set up the certificate by using certificate installation wizard if not OpenSSL.

You can follow the Add SSL to Solr instructions on URL https://horizontalintegration.blog/2018/03/06/sitecore-9-0-installation-with-sif/

0

Nowadays, there is a better script to setup secured Solr as a Windows service. No manually download is required, including JRE.

The script will accomplish these tasks.

  1. It will download and install latest version of JRE (64 bit or 32 bi)
  2. It will download any version of Solr
  3. It will download version 2.24.
  4. It will set JAVA_HOME environment variable
  5. It will sets up SSL for Solr (if certification does not exist it will generate one)
  6. It will add Solr host name to the host file
  7. It will utilize NSSM to setup Solr as Windows service
  8. It will open the Solr admin page.

Script Location: https://github.com/erjan123/Sitecore/blob/master/Sitecore/PowershellScripts/Sitecore%20Solr/2.Installing-Uninstalling-Solr-JRE.pptm

Tutorial:
https://www.youtube.com/watch?v=3-27syl8C98&t=1s

Note: The original script is from Jeremy Davis, I only added the JRE part to the script.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.