Generating a Certificate for a Sitecore Local Test Instance

To secure your local Sitecore development environment with HTTPS, you’ll need to create and install a self-signed SSL certificate. Here’s a step-by-step guide:

Option 1: Using PowerShell (Recommended for Windows)

  1. Open PowerShell as Administrator
  2. Create a self-signed certificate:
   $cert = New-SelfSignedCertificate -DnsName "sitecore.local", "cm.sitecore.local", "www.sitecore.local" -CertStoreLocation "cert:\LocalMachine\My"
  1. Export the certificate to a file:
   $pwd = ConvertTo-SecureString -String "YourPassword" -Force -AsPlainText
   Export-PfxCertificate -Cert $cert -FilePath "C:\certs\sitecore.local.pfx" -Password $pwd
  1. Trust the certificate:
   Export-Certificate -Cert $cert -FilePath "C:\certs\sitecore.local.cer"
   Import-Certificate -FilePath "C:\certs\sitecore.local.cer" -CertStoreLocation "Cert:\LocalMachine\Root"

Option 2: Using OpenSSL

  1. Install OpenSSL if you don’t have it already
  2. Generate a private key:
   openssl genrsa -out sitecore.local.key 2048
  1. Create a certificate signing request (CSR):
   openssl req -new -key sitecore.local.key -out sitecore.local.csr

(Fill in the details when prompted)

  1. Generate the self-signed certificate:
   openssl x509 -req -days 365 -in sitecore.local.csr -signkey sitecore.local.key -out sitecore.local.crt
  1. Convert to PFX format (for IIS):
   openssl pkcs12 -export -out sitecore.local.pfx -inkey sitecore.local.key -in sitecore.local.crt

Configuring IIS

  1. Import the certificate:
  • Open IIS Manager
  • Click on Server Certificates
  • Click “Import” and select your .pfx file
  1. Bind the certificate to your Sitecore sites:
  • For each Sitecore site (CM, CD, etc.)
  • Edit bindings
  • Add HTTPS binding and select your certificate

Updating Hosts File

Add entries to your hosts file (C:\Windows\System32\drivers\etc\hosts):

127.0.0.1 sitecore.local
127.0.0.1 cm.sitecore.local
127.0.0.1 www.sitecore.local

For Sitecore Containers (Docker)

If using Sitecore Docker containers, you’ll need to:

  1. Place the certificate in your Docker build context
  2. Update your docker-compose.override.yml to include the certificate
  3. Configure Traefik or your reverse proxy to use the certificate

Important Notes

  • Self-signed certificates will show browser warnings (this is normal for local development)
  • For production environments, always use certificates from trusted Certificate Authorities
  • Make sure your certificate’s subject name matches your Sitecore hostnames
  • You may need to restart IIS after certificate installation

Would you like more specific instructions for any particular part of this process?

FacebookTwitterEmailShare

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.