Adding HTTPS to Sitecore
For some reason although SIF adds SSL bindings for Identity Server and xConnect it doesn't do it for Sitecore. I like to generate a cert for *.dev.local and *sc, which we can do by tapping into the Invoke-NewSignedCertificateTask exposed by the Powershell module.There are a couple of ways you can retrieve the Sitecore root cert (which you'll need for signing), but I prefer to be sure I have the correct one (since I have a couple with the same name) and find the thumbprint manually by going into the Certificate Manager (start->run 'certmgr'). Under Trusted Root Certificate Authorities look for DO_NOT_TRUST_SitecoreRootCert. Double click this, go to details, and scroll down to Thumbprint. You can then insert your thumbprint into the following Powershell script to generate a new cert (in this case a wildcard for *.dev.local with friendly name 'Local Dev Wildcard' and a password for which it prompts you).
$Signer = Get-ChildItem -Path 'Cert:\\LocalMachine\\Root\\YOURTHUMBPRINT' $SecurePassword = Read-Host -Prompt "Enter password" -AsSecureString $dnsName = "*.dev.local","127.0.0.1" Invoke-NewSignedCertificateTask -Signer $Signer -Path 'C:\certificates' -CertStoreLocation 'Cert:\LocalMachine\My' -Name "Local Dev Wildcard" -DnsName $dnsName -IncludePrivateKey -Password $SecurePassword
Don't forget to update your identity server
Sitecore.IdentityServer.Host.xml
to ensure your sitecore URLs have https!Updating SIF
Ok so it's obviously pretty straightforward to call manually, but in case you want to incorporate the SSL step into SIF, working backwards you'll need:- sitecore-XP0.json
- Add a step under
CreateBindings
with the following:
"CreateBindingsWithThumbprint": { "Description": "Configures the site bindings for the website.", "Type": "WebBinding", "Params": { "SiteName" : "[parameter('SiteName')]", "Add": [ { "HostHeader": "[parameter('DNSName')]", "Protocol": "https", "SSLFlags": 1, "Thumbprint": "[variable('Security.Sitecore.CertificateThumbprint')]" } ] }, "Skip": "[not(parameter('SitecoreCert'))]" },
- Add a variable to the Variables section in the middle called
Security.Sitecore.CertificateThumbprint
with value"[GetCertificateThumbprint(parameter('SitecoreCert'), variable('Security.CertificateStore'))]"
- Add a parameter to the Parameters section at the top called
SitecoreCert
(I put it below xConnectCert so it's easy to find)
- Add a step under
- In XP0-SingleDeveloper.json
- Add parameter
SitecoreXP0:SitecoreCert
type String, ReferenceSitecoreCertificateName
to pass the cert name to the XP0 script above - Under Includes after
SitecoreSolr
add:"SitecoreCertificates": { "Source": ".\\createcert.json" },
- Add parameter
SitecoreCertificates:CertificateName
type String ReferenceSitecoreCertificateName
to pass the cert name to thecreatecert
script above - Add parameter
SitecoreCertificateName
type String, defaultValue "" to hold the cert name - In XP0-SingleDeveloper.ps1
- In the $singleDeveloperParams add:
SitecoreCertificateName = $SitecoreSiteName
to pass the cert name
- In the $singleDeveloperParams add:
Sitecore Installation Location
Unfortunately this one is nowhere near is nice :( I have no idea why the location is hardcoded- sitecore-XP0.json
- set
Site.PhysicalPath
to"[joinpath(environment('SystemDrive'), parameter('InstallLocation'), parameter('SiteName'))]"
- Add parameter
InstallLocation
optionally with"DefaultValue": "[joinpath('inetpub','wwwroot')]"
- set
- IdentityServer.json
- set
Site.PhysicalPath
to"[joinpath(environment('SystemDrive'), parameter('InstallLocation'), parameter('SiteName'))]"
- Add parameter
InstallLocation
optionally with"DefaultValue": "[joinpath('inetpub','wwwroot')]"
- set
- xconnect-xp0.json
- set
Site.PhysicalPath
to"[joinpath(environment('SystemDrive'), parameter('InstallLocation'), parameter('SiteName'))]"
- Add parameter
InstallLocation
optionally with"DefaultValue": "[joinpath('inetpub','wwwroot')]"
- set
- XP0-SingleDeveloper.json
- Add parameter
SitecoreXP0:InstallLocation
type String with"Reference": "InstallLocation"
- Add parameter
XConnectXP0:InstallLocation
type String with"Reference": "InstallLocation"
- Add parameter
IdentityServer:InstallLocation
type String with"Reference": "InstallLocation"
- Add parameter
InstallLocation
type String with"DefaultValue": "[joinpath('inetpub','wwwroot')]"
- Add parameter
- XP0-SingleDeveloper.ps1
- Under
$singleDeveloperParams
addInstallLocation = $InstallLocation
- Define your instllation variable above:
$InstallLocation = "\sites\mysite"
- Under
No comments:
Post a Comment