XConnectRocks

Sitecore Hackathon 2018 – By Bengaluru Rockstars @jimms @ddsundaria @ajiv

A machine learning app which reads emails from marketers inbox, filter out emails from important customers and process its against microsoft cognitive services and identify Email talks about business and then record it as “Offline Interactions” to XDB using XConnect API.

Currently there is no option available in sitecore to track offline email communications and we have created a app to scan local emails available on local inbox and based on the content of emails interaction are tracked across identified contacts, record important interactions to xDB. Advantage of this app is that they can use this app to see unread\missed communications on sitecore, so that they can get all interactions even if customer has just sent out an email about their request, the interactions can come in form of an email also and the app understands type of request by using LUIS.

Think about a scenario you have “Request a free traial” or “Request for Demo” button on website and that triggers a user formand triggers goals to sitecore only after successfully submitting the form. User is an important client for our business, he doesn’t want to go through all process of filling/validating form fields, instead he just sent out an email to “contact us” email id requesting for same thing. This request can missed by marketing team and our app just solves that problem.

RequestForDemo

Solution

A console application which we have created to showcase omni-channel capabilities of xConnect, this is mainly for tracking the offline email communication happening with marketing team\call center agents. Most of us will be having outlook at our machines runs and we are utilizing that to get offline interactions. This console application runs at local machine and scans unread email sand the content will be processed against natural processing language API LUIS and recognize important transactions.   This application reads markets’ inbox and notify users about unread transactions happening, we have set up a dashboard on sitecore content editor and user will be able to see the current day reports there, like users who initiated goals & their email subject. The real catch in the implementation is that the mails will be placed I to LIUS queue only if that sender email id is a valid/identified visitor on the site.  This app reads unread emails from marketer’s local inbox and scan the email content. This email content will be passed to LUIS to identify the intent type, once intent has been identified the corresponding goal will be fetched from sitecore and that will be triggered against that identified contact. This app consider only the emails from valid\identified clients and client identification happen through email.

How It works 

XConnect_flow

Steps :

  • Scans today’s email from marketer’s inbox using Outlook and its reads unread email from the system.
  • Pass email id to the xConnect API and checks whether its from an identified customer or not.
  • Once the system identifies its from a important customer, then read the mail boy and process it against LUIS.  We have used LUIS for processing email content and its identifies whether email talks about your business and important interaction.
  • Goals have been set in sitecore and the intent retrieved by LUIS is processed against sitecore to validate whether its a actual goal for visitor or NOT. The Important interactions has been recorded  as “Offline Interactions” to Sitecore XDB using API.
  • We have set a dashboard in sitecore, marketers can use this dashboard to see offline interactions from customers. This actually helps marketers to keep track of miseed interaction from customers.

XConnectRocks dashboard

This is a sample dashboard ,  this is just a sample we shared as part of #SCHackathon.  🙂 dont focus too much on content, its  a sample based on content we had in our inbox. Same can be visible on sitecore Analytics dashboards as we are triggering goals against visits, same as Page Visits information.

XConnect_dasboard.png

It was really fun to see how we have identified/solved this problem. Initial three to four hours of blankness after getting categories and rethinking scenarios on SXA, marketing automation capabilities it was all like implementing something already available with sitecore. And Commerce 9 we were stuck at that “not a valid SSL” error. So finally we got this idea and just concentrated on completing the story. We are very much happy in completing this story as its a very useful case for Sitecore customers. It was fun and lets continue our journey with sitecore 🙂

You might be thinking about the security aspect of this implementation, whether its going to read my personal emails and that’s what the catch we have put in the implementation. “Identified visitors from Site” this app will consider only the mails from valid customers, the email id which is available in sitecore,  identified  contacts will be having valid email id. We are interested only in business emails , not the personal emails. Thanks Gaurav for highlighting that issue and we have already covered that as part of implementation.

Why Outlook , same can be done with Social media rt? yes of cource, preferred outlook because of time constraints, the target was to complete the working piece in that remaining hours, idea has come up during the #SCHackathon and all other things we can plan as part of official release 🙂

How to Install sitecore 9 with SOLR SSL in single step

This article talks about way to install Sitecore9 in single script execution, it includes installation with SOLR version with defined SSL port and installation of complete sitecore website, xconnect platform.

I was thinking of a blog to start with and definitely, Sitecore9 installation steps will definitely the perfect candidate this time. As you can find it many other blogs it includes a lot of steps I have gone through those and got stuck many time. Initially planned to share my own installation steps in my blog, but then thought about creating a single script file which does all those work for us you can install sitecore 9 in just a single click once u have installed correct tools in your machine. This uses “Packages for XP Single” package as its mainly for sitecore developers like me who used to do the sitecore installation with just one file execution. Just run this power shell script and all is all set for u. This script is resulted file of information which I got from many other blogs and reference links are attached below. So before executing this script download and install following tools in your local machine.

  1. Powershell 5.1
  2. MS SQL Server 2016 SP1
  3. MS SQL Management Studio
  4. .Net Framework 4.6.2
  5. Web Deploy 3.6
  6. Java Runtime Environment
  7. SQL Server® Data-Tier Application Framework
  8. Packages for XP Single (On Premises deployment)

Download file and keep it in the set-up folder and the file is available as  shown below on the download page.
XPSingle9

9.Install IIS on your local machine

Execution Steps

  1. Download the following package from GitHub and extract to same folder as shown below.

folder.png

Edit InstallSitecoreInstance.ps1. Edit the file and Update following properties in that script file.

$SqlServer = “SQL Server Name”
$SqlAdminUser = “SQL Server admin user Id”
$SqlAdminPassword=”SQL Server Password”
$SolrVersionNumber =’6.6.2′ #Version should be 6.6.2 or later

Open powershell in Run As Administrator mode. Go to instance folder execute this script file as shown below.

if you are getting the error “File [.ps1] cannot be loaded because the execution of scripts is disabled on this system. Please see “get-help about_signing” for more details.” please execute the below line on PowerShell window.

Set-ExecutionPolicy -Scope CurrentUser Unrestricted

execute

This installation deploye ur solr instance in ur set-up folder and you need to change following parameter if you need to  deploy to other folder.

$SolrInstallPath=”<folder path>”

Update PostInstallScripts.sql to perform the post Installation scripts on sql server

 

Troubleshetting steps are listed below and which will help you to resolve issues you are getting while using this script.

#define parameters
$prefix = "HackathonSite"
$SqlServer = "[Sql server name]"
$SqlAdminUser = "[Admin user name]"
$SqlAdminPassword="[AdminPassword]"
$SolrVersionNumber ='6.6.2'
$KeyToolFilePath ='C:\Program Files\Java\jre1.8.0_162\bin\keytool.exe'
$SQLCommandBinFolderPath ='C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn'
$SitecoreBuildVersionVersion = '9.0.1 rev. 171219'
$XConnectCollectionService = "$prefix.xconnect"
$SolrVersion ="solr-$SolrVersionNumber"
$SolrPortNumber="8547"
$SolrInstallPath=""
$sitecoreSiteName = "$prefix.sc"
$output = "$PSScriptRoot\$SolrVersion.zip"
$KeyToolFilePath ='C:\Program Files\Java\jre1.8.0_162\bin\keytool.exe'
$solrdownloadurl = "http://archive.apache.org/dist/lucene/solr/$SolrVersionNumber/$SolrVersion.zip"
$SolrServiceName = "HackathonTemp-$SolrVersion" #change this if you want to customise service name
$SolrUrl = "https://localhost:$SolrPortNumber/solr"
$SolrRoot = "$PSScriptRoot\$SolrVersion"
$start_time = Get-Date
Write-Host '*******Setting up preinstallation steps*******'
$PSScriptOutputRoot ="$PSScriptRoot\Output"
$NSSMZipPath = "$PSScriptRoot\nssm-2.24.zip"
$NSSMUnZipPath = "$PSScriptRoot"
$NSSMUnZipFolder = "$PSScriptRoot\nssm-2.24"
# $SolrServiceName = "$SolrVersion"
if (Get-Service $SolrServiceName ErrorAction SilentlyContinue) {
Stop-Service $SolrServiceName
powershell Command "$NSSMUnZipFolder\win64\nssm remove $SolrServiceName confirm"
}
if(!(Test-Path $output)) {
Write-Host "Getting Solr zip file…$solrdownloadurl as $output"
try
{
Invoke-WebRequest Uri $solrdownloadurl OutFile $output
Write-Output "Time taken: $((Get-Date).Subtract($start_time).Seconds) second(s)"
} catch{
Write-Host '*******This version is not availble for download*******'
}
}
if((Test-Path $PSScriptOutputRoot)) {
Remove-Item $PSScriptOutputRoot recurse Exclude "Output"
}
else
{
New-Item ItemType Directory Force Path $PSScriptOutputRoot
}
$NSSMurl = "https://nssm.cc/release/nssm-2.24.zip"
$NSSoutput = "$PSScriptRoot\nssm-2.24.zip"
$start_time = Get-Date
if(!(Test-Path $NSSoutput)) {
Write-Host 'Getting NSSM zip file…'
Invoke-WebRequest Uri $NSSMurl OutFile $NSSoutput
Write-Output "Time taken: $((Get-Date).Subtract($start_time).Seconds) second(s)"
}
$SolrZipPath = "$PSScriptRoot\$SolrVersion.zip"
$SolrUnZipPath = "$PSScriptRoot"
$SolrHome = "$PSScriptRoot\$SolrVersion"
if($SolrInstallPath -ne "")
{
$SolrHome = "$SolrInstallPath\$SolrVersion"
$SolrUnZipPath = "$SolrInstallPath"
}
if((Test-Path $SolrHome)) {
Write-Host "Removing existing solr extract folder $SolrHome"
Remove-Item path $SolrHome Recurse
}
Write-Host "Extracting Solr zip file… $SolrZipPath to $SolrUnZipPath"
Add-Type assembly "system.io.compression.filesystem"
[io.compression.zipfile]::ExtractToDirectory($SolrZipPath, $SolrUnZipPath)
if((Test-Path $NSSMUnZipFolder)) {
Write-Host "Removing existing NSSM extract folder $NSSMUnZipFolder"
Remove-Item path $NSSMUnZipFolder Recurse
}
Write-Host 'Extracting NSSM zip file…'
Add-Type assembly "system.io.compression.filesystem"
[io.compression.zipfile]::ExtractToDirectory($NSSMZipPath, $NSSMUnZipPath)
Write-Host ''
Write-Host 'Setting Up Solr Service…'
$NSSMbinPath = "$PSScriptRoot\nssm-2.24\win64"
if (Get-Service $SolrServiceName ErrorAction SilentlyContinue) {
Write-Host "Setting SSL for SOLR service"
Write-Host "Stopping $SolrServiceName"
Stop-Service $SolrServiceName
powershell Command "$NSSMUnZipFolder\win64\nssm remove $SolrServiceName confirm"
powershell Command "$NSSMUnZipFolder\win64\nssm install $SolrServiceName '$SolrHome\bin\solr.cmd' 'start -f -p $SolrPortNumbers"
Start-Service $SolrServiceName
} else {
Write-Host "Setting SSL for SOLR service"
Write-Host "$Create service $SolrServiceName"
powershell Command "$NSSMUnZipFolder\win64\nssm install $SolrServiceName '$SolrHome\bin\Solr.cmd' 'start -f -p $SolrPortNumber'"
Start-Service $SolrServiceName
}
Write-Host "Setting SSL for SOLR service"
$JKSPath="$PSScriptRoot\solr-ssl.keystore.p12"
# remove existing jks and p12 files
if((Test-Path $JKSPath)) {
Write-Host "removing existing keys"
Remove-Item path $PSScriptRoot\solrssl.keystore.jks
Remove-Item path $PSScriptRoot\solrssl.keystore.p12
}
else
{
Write-Host "p12 is not available and it will be regenerated"
}
$JKSPath="$PSScriptRoot\solr-ssl.keystore.jks"
if((Test-Path $JKSPath)) {
Write-Host "removing existing keys"
Remove-Item path $PSScriptRoot\solrssl.keystore.jks
Remove-Item path $PSScriptRoot\solrssl.keystore.p12
}
else
{
Write-Host "jks is not available and it will be regenerated"
}
Write-Host "Generating Keys $KeyToolFilePath"
./solrssl KeyToolFilePath $KeyToolFilePath
$SolrCommands =@"
set SOLR_SSL_KEY_STORE=$SolrHome\bin\etc\solr-ssl.keystore.jks
set SOLR_SSL_KEY_STORE_PASSWORD=secret
set SOLR_SSL_TRUST_STORE=$SolrHome\bin\etc\solr-ssl.keystore.jks
set SOLR_SSL_TRUST_STORE_PASSWORD=secret
"@
$SolrBINCommand ="$SolrHome\bin\solr.in.cmd"
$SolrEtcFolder ="$SolrHome\bin\etc"
if(!(Test-Path $SolrEtcFolder)) {
New-Item ItemType Directory Force Path $SolrEtcFolder
}
Write-Host 'Copying certificate files to Solr folder…'
Copy-Item $PSScriptRoot\solrssl.keystore.jks $SolrEtcFolder
Copy-Item $PSScriptRoot\solrssl.keystore.p12 $SolrEtcFolder
Add-Content $SolrBINCommand $SolrCommands
$SolrDefaultConfigsPath="$SolrHome\server\solr\configsets\_default"
$SolrDefaultConfigs ="basic_configs"
if((Test-Path $SolrDefaultConfigsPath)) {
$SolrDefaultConfigs ="_default"
}
$SolrConfigFolder ="$SolrHome\server\solr\configsets\$SolrDefaultConfigs\conf"
Write-Host "Restarting solr service $SolrUrl"
if (Get-Service $SolrServiceName ErrorAction SilentlyContinue) {
powershell Command "$NSSMUnZipFolder\win64\nssm stop $SolrServiceName "
}
powershell Command "$NSSMUnZipFolder\win64\nssm start $SolrServiceName "
Start-Sleep s 20
Write-Host "************HTTPS Solr Service is started successfully"
Write-Host "You can access service at $SolrUrl"
$SitecorePackage = "$PSScriptRoot\Sitecore $SitecoreBuildVersionVersion (WDP XP0 packages).zip"
$SitecorePackageUnZipPath = "$PSScriptOutputRoot"
Write-Host "Connection to sql servr"
$ConnectionString = "Data Source=$SqlServer;Initial Catalog=master;User Id=$SqlAdminUser;Password=$SqlAdminPassword;"
$connection = New-Object System.Data.SqlClient.SqlConnection($ConnectionString);
$command = New-Object System.Data.SqlClient.SqlCommand;
$command.Connection = $connection;
$command.CommandType = [System.Data.CommandType]::Text;
$command.CommandText = @"
sp_configure 'contained database authentication',1;
"@;
$connection.open();
$reader = $command.ExecuteReader()
While($reader.Read()){
Write-Host 'Copying certificate file to Solr folder…$reader.'
}
Write-Host 'Copying certificate file to Solr folder…$reader.'
$connection.Close()
$reader.Close()
$command.CommandText = @"
RECONFIGURE;
"@;
$connection.open();
$reader = $command.ExecuteReader()
While($reader.Read()){
Write-Host 'Copying certificate file to Solr folder…$reader.'
}
Write-Host 'Copying certificate file to Solr folder…$reader.'
$connection.Close()
$reader.Close()
Write-Host "**********Database contained authentication has been set succssfully*******************"
Write-Host 'Extracting $SitecorePackage XP0 packages zip file…'
Add-Type assembly "system.io.compression.filesystem"
[io.compression.zipfile]::ExtractToDirectory($SitecorePackage, $SitecorePackageUnZipPath)
$SitecorePackage = "$PSScriptOutputRoot\XP0 Configuration files $SitecoreBuildVersionVersion.zip"
Write-Host 'Extracting zip file…'
Add-Type assembly "system.io.compression.filesystem"
[io.compression.zipfile]::ExtractToDirectory($SitecorePackage, $SitecorePackageUnZipPath)
Write-Host "Copy Config files to setup path"
#Copy-Item $PSScriptOutputRoot\sitecore-solr.json $PSScriptRoot
#Copy-Item $PSScriptOutputRoot\sitecore-XP0.json $PSScriptRoot
#Copy-Item $PSScriptOutputRoot\xconnect-createcert.json $PSScriptRoot
#Copy-Item $PSScriptOutputRoot\xconnect-solr.json $PSScriptRoot
#Copy-Item $PSScriptOutputRoot\xconnect-xp0.json $PSScriptRoot
# Add the Sitecore MyGet repository to PowerShell
Register-PSRepository Name SitecoreGallery SourceLocation https://sitecore.myget.org/F/scpowershell/api/v2
# Install the Sitecore Install Framwork module
if (Get-Module ListAvailable Name SitecoreInstallFramework)
{
Write-Host "SitecoreInstallFramework module exists"
}
else
{
Install-Module SitecoreInstallFramework Confirm
}
# Install the Sitecore Fundamentals module (provides additional functionality for local installations like creating self-signed certificates)
if (Get-Module ListAvailable Name SitecoreFundamentals)
{
Write-Host "SitecoreInstallFramework module exists"
}
else
{
Install-Module SitecoreFundamentals Confirm
}
# Import the modules into your current PowerShell context (if necessary)
Import-Module SitecoreFundamentals
Import-Module SitecoreInstallFramework
# ./install
<#
$solrParams = @{
Path = "$PSScriptOutputRoot\sitecore-solr.json"
SolrUrl = $SolrUrl
SolrRoot = $SolrRoot
SolrService = $SolrServiceName
CorePrefix = $prefix
}
#Install-SitecoreConfiguration @solrParams
#>
#install client certificate for xconnect
$certParams = @{
Path = "$PSScriptOutputRoot\xconnect-createcert.json"
CertificateName = "$prefix.xconnect_client"
}
Install-SitecoreConfiguration @certParams Verbose
#install solr cores for xdb
$solrParams =
@{
Path = "$PSScriptOutputRoot\xconnect-solr.json"
SolrUrl = $SolrUrl
SolrRoot = $SolrRoot
SolrService = $SolrServiceName
CorePrefix = $prefix
BaseConfig = $SolrDefaultConfigs
}
Install-SitecoreConfiguration @solrParams Verbose
#deploy xconnect instance
$xconnectParams = @{
Path = "$PSScriptOutputRoot\xconnect-xp0.json"
Package = "$PSScriptOutputRoot\Sitecore $SitecoreBuildVersionVersion (OnPrem)_xp0xconnect.scwdp.zip"
LicenseFile = "$PSScriptRoot\license.xml"
Sitename = $XConnectCollectionService
XConnectCert = $certParams.CertificateName
SqlDbPrefix = $prefix
SqlServer = $SqlServer
SqlAdminUser = $SqlAdminUser
SqlAdminPassword = $SqlAdminPassword
SolrCorePrefix = $prefix
SolrURL = $SolrUrl
}
Install-SitecoreConfiguration @xconnectParams Verbose
#install solr cores for sitecore $solrParams =
$solrParams = @{
Path = "$PSScriptOutputRoot\sitecore-solr.json"
SolrUrl = $SolrUrl
SolrRoot = $SolrRoot
SolrService = $SolrServiceName
CorePrefix = $prefix
}
Install-SitecoreConfiguration @solrParams
#install sitecore instance
$xconnectHostName = "$prefix.xconnect"
$sitecoreParams =
@{
Path = "$PSScriptOutputRoot\sitecore-XP0.json"
Package = "$PSScriptOutputRoot\Sitecore $SitecoreBuildVersionVersion (OnPrem)_single.scwdp.zip"
LicenseFile = "$PSScriptRoot\license.xml"
SqlDbPrefix = $prefix
SqlServer = $SqlServer
SqlAdminUser = $SqlAdminUser
SqlAdminPassword = $SqlAdminPassword
SolrCorePrefix = $prefix
SolrUrl = $SolrUrl
XConnectCert = $certParams.CertificateName
Sitename = $sitecoreSiteName
XConnectCollectionService = "https://$XConnectCollectionService"
}
Install-SitecoreConfiguration @sitecoreParams
Write-Host '*****Post Installation Task started***********e…'
Write-Host "Executing sql scripts… $SQLCommandBinFolderPath\sqlcmd -S $SqlServer -U $SqlAdminUser -P $SqlAdminPassword -i $PSScriptRoot\PostInstallScripts.sql"
$InputFile = @"
$SQLCommandBinFolderPath\sqlcmd -S $SqlServer -U $SqlAdminUser -P $SqlAdminPassword -i
"@
Invoke-Sqlcmd InputFile $PSScriptRoot\PostInstallScripts.sql

:SETVAR DatabasePrefix SC9DemoXP0
:SETVAR UserName collectionuser
:SETVAR Password Test12345
:SETVAR ShardMapManagerDatabaseNameSuffix _Xdb.Collection.ShardMapManager
:SETVAR Shard0DatabaseNameSuffix _Xdb.Collection.Shard0
:SETVAR Shard1DatabaseNameSuffix _Xdb.Collection.Shard1
GO
IF(SUSER_ID('$(UserName)') IS NULL)
BEGIN
CREATE LOGIN [$(UserName)] WITH PASSWORD = '$(Password)';
END;
GO
USE [$(DatabasePrefix)$(ShardMapManagerDatabaseNameSuffix)]
IF NOT EXISTS (SELECT * FROM sys.database_principals WHERE name = N'$(UserName)')
BEGIN
CREATE USER [$(UserName)] FOR LOGIN [$(UserName)]
GRANT SELECT ON SCHEMA :: __ShardManagement TO [$(UserName)]
GRANT EXECUTE ON SCHEMA :: __ShardManagement TO [$(UserName)]
END;
GO
USE [$(DatabasePrefix)$(Shard0DatabaseNameSuffix)]
IF NOT EXISTS (SELECT * FROM sys.database_principals WHERE name = N'$(UserName)')
BEGIN
CREATE USER [$(UserName)] FOR LOGIN [$(UserName)]
EXEC [xdb_collection].[GrantLeastPrivilege] @UserName = '$(UserName)'
END;
GO
USE [$(DatabasePrefix)$(Shard1DatabaseNameSuffix)]
IF NOT EXISTS (SELECT * FROM sys.database_principals WHERE name = N'$(UserName)')
BEGIN
CREATE USER [$(UserName)] FOR LOGIN [$(UserName)]
EXEC [xdb_collection].[GrantLeastPrivilege] @UserName = '$(UserName)'
END;
GO

USE master;
ALTER DATABASE xp0_Core SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
DROP DATABASE xp0_Core ;
ALTER DATABASE xp0_ExperienceForms SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
DROP DATABASE xp0_ExperienceForms
ALTER DATABASE xp0_MarketingAutomation SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
DROP DATABASE xp0_MarketingAutomation
ALTER DATABASE xp0_Master SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
DROP DATABASE xp0_Master
ALTER DATABASE [xp0_Processing.Pools] SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
DROP DATABASE [xp0_Processing.Pools]
ALTER DATABASE [xp0_Processing.Tasks] SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
DROP DATABASE [xp0_Processing.Tasks]
ALTER DATABASE xp0_ReferenceData SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
DROP DATABASE xp0_ReferenceData
ALTER DATABASE xp0_Reporting SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
DROP DATABASE xp0_Reporting
ALTER DATABASE xp0_Web SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
DROP DATABASE xp0_Web
ALTER DATABASE [xp0_Xdb.Collection.Shard0] SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
DROP DATABASE [xp0_Xdb.Collection.Shard0]
ALTER DATABASE [xp0_Xdb.Collection.Shard1] SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
DROP DATABASE [xp0_Xdb.Collection.Shard1]
ALTER DATABASE [xp0_Xdb.Collection.ShardMapManager] SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
DROP DATABASE [xp0_Xdb.Collection.ShardMapManager]

view raw
Script to delete db
hosted with ❤ by GitHub

param(
[string]$KeystoreFile = 'solr-ssl.keystore.jks',
[string]$KeystorePassword = 'secret',
[string]$SolrDomain = 'localhost',
[switch]$Clobber
)
$ErrorActionPreference = 'Stop'
### PARAM VALIDATION
if($KeystorePassword -ne 'secret') {
Write-Error 'The keystore password must be "secret", because Solr apparently ignores the parameter'
}
if((Test-Path $KeystoreFile)) {
if($Clobber) {
Write-Host "Removing $KeystoreFile"
Remove-Item $KeystoreFile
} else {
$KeystorePath = Resolve-Path $KeystoreFile
Write-Error "Keystore file $KeystorePath already existed. To regenerate it, pass -Clobber."
}
}
$P12Path = [IO.Path]::ChangeExtension($KeystoreFile, 'p12')
if((Test-Path $P12Path)) {
if($Clobber) {
Write-Host "Removing $P12Path"
Remove-Item $P12Path
} else {
$P12Path = Resolve-Path $P12Path
Write-Error "Keystore file $P12Path already existed. To regenerate it, pass -Clobber."
}
}
try {
$keytool = (Get-Command 'keytool.exe').Source
} catch {
$keytool = 'C:\Program Files\Java\jre1.8.0_151\bin\keytool.exe'
if([string]::IsNullOrEmpty($keytool) -or -not (Test-Path $keytool)) {
Write-Error "Keytool path was invalid."
}
}
### DOING STUFF
Write-Host ''
Write-Host 'Generating JKS keystore…'
& $keytool genkeypair alias solrssl keyalg RSA keysize 2048 keypass $KeystorePassword storepass $KeystorePassword validity 9999 keystore $KeystoreFile ext SAN=DNS:$SolrDomain,IP:127.0.0.1 dname "CN=$SolrDomain, OU=Organizational Unit, O=Organization, L=Location, ST=State, C=Country"
Write-Host ''
Write-Host 'Generating .p12 to import to Windows…'
& $keytool importkeystore srckeystore $KeystoreFile destkeystore $P12Path srcstoretype jks deststoretype pkcs12 srcstorepass $KeystorePassword deststorepass $KeystorePassword
Write-Host ''
Write-Host 'Trusting generated SSL certificate…'
$secureStringKeystorePassword = ConvertTo-SecureString String $KeystorePassword Force AsPlainText
$root = Import-PfxCertificate FilePath $P12Path Password $secureStringKeystorePassword CertStoreLocation Cert:\LocalMachine\Root
Write-Host 'SSL certificate is now locally trusted. (added as root CA)'
Write-Host ''
Write-Host '########## NEXT STEPS ##########' ForegroundColor Green
Write-Host ''
Write-Host '1. Copy your keystore to $SOLR_HOME\server\etc (MUST be here)' ForegroundColor Green
if(-not $KeystoreFile.EndsWith('solr-ssl.keystore.jks')) {
Write-Warning 'Your keystore file is not named "solr-ssl.keystore.jks"'
Write-Warning 'Solr requires this exact name, so make sure to rename it before use.'
}
$KeystorePath = Resolve-Path $KeystoreFile
Write-Host ''
Write-Host '2. Add the following lines to your solr.in.cmd:' ForegroundColor Green
Write-Host ''
Write-Host "set SOLR_SSL_KEY_STORE=etc/solr-ssl.keystore.jks" ForegroundColor Yellow
Write-Host "set SOLR_SSL_KEY_STORE_PASSWORD=$KeystorePassword" ForegroundColor Yellow
Write-Host "set SOLR_SSL_TRUST_STORE=etc/solr-ssl.keystore.jks" ForegroundColor Yellow
Write-Host "set SOLR_SSL_TRUST_STORE_PASSWORD=$KeystorePassword" ForegroundColor Yellow
Write-Host ''
Write-Host 'Done!'

view raw
solrssl.ps1
hosted with ❤ by GitHub

Trouble shooting steps

This script file is result of information which I got from many blogs ralated to Sitecore9 and there are many so thank you Sitecore community for providing us details.

Reference Links:

How to Install Sitecore 9 with the Sitecore Install Framework

param(
[string]$KeystoreFile = 'solr-ssl.keystore.jks',
[string]$KeystorePassword = 'secret',
[string]$SolrDomain = 'localhost',
[switch]$Clobber
)
$ErrorActionPreference = 'Stop'
### PARAM VALIDATION
if($KeystorePassword -ne 'secret') {
Write-Error 'The keystore password must be "secret", because Solr apparently ignores the parameter'
}
if((Test-Path $KeystoreFile)) {
if($Clobber) {
Write-Host "Removing $KeystoreFile"
Remove-Item $KeystoreFile
} else {
$KeystorePath = Resolve-Path $KeystoreFile
Write-Error "Keystore file $KeystorePath already existed. To regenerate it, pass -Clobber."
}
}
$P12Path = [IO.Path]::ChangeExtension($KeystoreFile, 'p12')
if((Test-Path $P12Path)) {
if($Clobber) {
Write-Host "Removing $P12Path"
Remove-Item $P12Path
} else {
$P12Path = Resolve-Path $P12Path
Write-Error "Keystore file $P12Path already existed. To regenerate it, pass -Clobber."
}
}
try {
$keytool = (Get-Command 'keytool.exe').Source
} catch {
$keytool = Read-Host "keytool.exe not on path. Enter path to keytool (found in JRE bin folder)"
if([string]::IsNullOrEmpty($keytool) -or -not (Test-Path $keytool)) {
Write-Error "Keytool path was invalid."
}
}
### DOING STUFF
Write-Host ''
Write-Host 'Generating JKS keystore…'
& $keytool genkeypair alias solrssl keyalg RSA keysize 2048 keypass $KeystorePassword storepass $KeystorePassword validity 9999 keystore $KeystoreFile ext SAN=DNS:$SolrDomain,IP:127.0.0.1 dname "CN=$SolrDomain, OU=Organizational Unit, O=Organization, L=Location, ST=State, C=Country"
Write-Host ''
Write-Host 'Generating .p12 to import to Windows…'
& $keytool importkeystore srckeystore $KeystoreFile destkeystore $P12Path srcstoretype jks deststoretype pkcs12 srcstorepass $KeystorePassword deststorepass $KeystorePassword
Write-Host ''
Write-Host 'Trusting generated SSL certificate…'
$secureStringKeystorePassword = ConvertTo-SecureString String $KeystorePassword Force AsPlainText
$root = Import-PfxCertificate FilePath $P12Path Password $secureStringKeystorePassword CertStoreLocation Cert:\LocalMachine\Root
Write-Host 'SSL certificate is now locally trusted. (added as root CA)'
Write-Host ''
Write-Host '########## NEXT STEPS ##########' ForegroundColor Green
Write-Host ''
Write-Host '1. Copy your keystore to $SOLR_HOME\server\etc (MUST be here)' ForegroundColor Green
if(-not $KeystoreFile.EndsWith('solr-ssl.keystore.jks')) {
Write-Warning 'Your keystore file is not named "solr-ssl.keystore.jks"'
Write-Warning 'Solr requires this exact name, so make sure to rename it before use.'
}
$KeystorePath = Resolve-Path $KeystoreFile
Write-Host ''
Write-Host '2. Add the following lines to your solr.in.cmd:' ForegroundColor Green
Write-Host ''
Write-Host "set SOLR_SSL_KEY_STORE=etc/solr-ssl.keystore.jks" ForegroundColor Yellow
Write-Host "set SOLR_SSL_KEY_STORE_PASSWORD=$KeystorePassword" ForegroundColor Yellow
Write-Host "set SOLR_SSL_TRUST_STORE=etc/solr-ssl.keystore.jks" ForegroundColor Yellow
Write-Host "set SOLR_SSL_TRUST_STORE_PASSWORD=$KeystorePassword" ForegroundColor Yellow
Write-Host ''
Write-Host 'Done!'

view raw
solrssl.ps1
hosted with ❤ by GitHub

https://buoctrenmay.wordpress.com/2017/10/30/a-step-by-step-guide-for-sitecore-9-installation-on-your-machine/

Gotchas while installing Sitecore 9 using the Sitecore installation framework