Friday, October 27, 2017

Connecting Sitecore Rocks to Sitecore 9 with Visual Studio 2017 securely

In Sitecore 9 you will not get access to install Hardrock services required by Sitecore Rocks to connect to Sitecore instance.

If you follow the normal process, you get following message when you try to connect

Sitecore Rocks Connection Error


To setup a connection you need authorize access to sitecore/shell/webservice location in web.config by adding a location attribute and allowing only authenticated users.

  
  <location path="sitecore/shell/WebService">

    <system.web>

      <authorization>

        <allow users="*" />

      </authorization>

    </system.web>

  </location>

Typically you will find other posts or suggestions to allow access to anonymous (?) and authenticated (*) users but that is not needed.

You should allow access to this location only for authenticated users

I tried to narrow it down further to allow only for a specific user e.g. to sitecore/admin but that simply throws back the same screen shown above and fiddler indicates that it is throwing the login page which means its not able to authenticate in that attempt.


Monday, October 23, 2017

Installing Solr 6.2.1 as a Windows Service for your Sitecore Installation

When I was trying to get Solr installed for my Sitecore 9 installation, I struggled to get it installed as Windows Service, but finally got it working. Here is what how I did it

Enabling SSL for your solr installation

First create self-signed certificate using keytool as shown below (I am executing this in the current path of C:\solr-6.2.1\server\etc

keytool
-genkeypair -alias solr-ssl -keyalg RSA -keysize 2048 -keypass <yoursecretpwd>-storepass <yourstorepwd> -validity 9999 -keystore solr-ssl.keystore.jks -ext
SAN=DNS:localhost,IP:127.0.0.1 -dname "CN=localhost, OU=Organizational
Unit, O=Organization, L=Location, ST=State, C=Country"

keytool -importkeystore -srckeystore solr-ssl.keystore.jks -destkeystore solr-ssl.keystore.p12 -srcstoretype jks -deststoretype
pkcs12

Now install certificate in the trusted authority store as shown below
Double-click the generated .p12 - for example, C:\Solr-6.2.1\server\etc\solr-ssl.keystore.p12 - and go through the wizard, selecting the following:
  • Store Location: Local Machine
  • File name: [NO CHANGE]
  • Password: secret (or the value of -keypass used in your own environment)
  • Certificate store: Trusted Root Certificate Authorities
  • Post that make sure your solr properties in solr.in.cmd (file is in the bin directory) is configured correctly to enable SSL. In my case this is how it looked like


set SOLR_SSL_KEY_STORE=C:\solr-6.2.1\server/etc/solr-ssl.keystore.jks

set SOLR_SSL_KEY_STORE_PASSWORD=<your ssl key store pwd>

set SOLR_SSL_TRUST_STORE=C:\solr-6.2.1\server/etc/solr-ssl.keystore.jks

set SOLR_SSL_TRUST_STORE_PASSWORD=<your ssl trust store password>

set SOLR_SSL_NEED_CLIENT_AUTH=false

set SOLR_SSL_WANT_CLIENT_AUTH=false


Usually I keep key store and trust store passwords the same

Running Solr as Windows Service

Your typical sc create command times out and does not result in successful start of the service (here is the command I used)

sc create Solr621 binPath="C:\Solr 6.2.1\bin\start.cmd start -f" DisplayName= "Solr 6.2.1" start= "auto"
sc start Solr621

After digging a bit, came across nssm (the non-sucking service manager :)) and downloaded the latest version

http://www.nssm.cc/download 

Once you install nssm (I used 2.24 version), open command prompt in administrative mode and execute this command

nssm install Solr621

Notes:

  • After unzipping nssm I added nssm path into PATH environment variable
  • The name Solr621 above can be any name you want to give your service


A window will open where you can mention the attributes as shown in the snapshot below

NSSM service properties

NSSM service display name and description


In the first screen above, set the path pointing to solr.cmd and startup directory as your solr installation bin directory.
Notice the arguments set to start solr service in foreground (start -f)

In the Details tab, enter the display name and description as you wish, with startup type as Automatic so that the service starts automatically when you restart your machine.

Note that this installation procedure is ideal for local machine installation. For production deployments refer to solr documentation

Happy Searching !!