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)
- Open PowerShell as Administrator
- Create a self-signed certificate:
$cert = New-SelfSignedCertificate -DnsName "sitecore.local", "cm.sitecore.local", "www.sitecore.local" -CertStoreLocation "cert:\LocalMachine\My"
- 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
- 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
- Install OpenSSL if you don’t have it already
- Generate a private key:
openssl genrsa -out sitecore.local.key 2048
- Create a certificate signing request (CSR):
openssl req -new -key sitecore.local.key -out sitecore.local.csr
(Fill in the details when prompted)
- Generate the self-signed certificate:
openssl x509 -req -days 365 -in sitecore.local.csr -signkey sitecore.local.key -out sitecore.local.crt
- Convert to PFX format (for IIS):
openssl pkcs12 -export -out sitecore.local.pfx -inkey sitecore.local.key -in sitecore.local.crt
Configuring IIS
- Import the certificate:
- Open IIS Manager
- Click on Server Certificates
- Click “Import” and select your .pfx file
- 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:
- Place the certificate in your Docker build context
- Update your docker-compose.override.yml to include the certificate
- 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?