Sitecore: Example powershell to clone new self signed certificate with same Root certificate.

$Path = "c:\\certificates"
$Name = "xp0.xconnect_client"
$Signer = Invoke-GetCertificateConfigFunction -Id 'DO_NOT_TRUST_SitecoreRootCert' -CertStorePath Cert:\LocalMachine\Root -Verbose
$Signer.GetType()
$DnsName = "xp0.xconnect_client"
$CertStoreLocation = 'Cert:\LocalMachine\My'
$signedCertificate = New-SelfSignedCertificate  -CloneCert $Signer -DnsName $DnsName -CertStoreLocation $CertStoreLocation -Verbose
                if ($null -eq $signedCertificate) {

                    throw "Failed to create signed certificate for '$DnsName' in $CertStoreLocation"
                }
                Write-Host "Created signed certificate $signedCertificate"


            Write-Host "Export new certificate public key as a CRT file"
            $exportFilePath = Join-Path -Path $Path -ChildPath "$Name.crt"
            $certificateInfo = Export-Certificate -Cert $signedCertificate -FilePath $exportFilePath -Force

            Write-Information -MessageData "Exported signed certificate to $exportFilePath"
  •  
  •  
  •  
  •  

Viet Luu has written 212 articles

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Buy Me A Coffee

We are thankful for your never ending support.

Leave a Reply