Skip to content

Instantly share code, notes, and snippets.

@naveed-ahmad-biz
Last active November 5, 2017 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save naveed-ahmad-biz/981bee0e019c59e13b76579bafa43b92 to your computer and use it in GitHub Desktop.
Save naveed-ahmad-biz/981bee0e019c59e13b76579bafa43b92 to your computer and use it in GitHub Desktop.
#generate certificate
$thumbprint = (New-SelfSignedCertificate `
-Subject "CN=$env:COMPUTERNAME @ Sitecore, Inc." `
-Type SSLServerAuthentication `
-FriendlyName "$env:USERNAME Certificate").Thumbprint
#export certificate with password
$certificateFilePath = "C:\Temp\$thumbprint.pfx"
Export-PfxCertificate `
-cert cert:\LocalMachine\MY\$thumbprint `
-FilePath "$certificateFilePath" `
-Password (Read-Host -Prompt "Enter password that would protect the certificate" -AsSecureString)
#convert it to base64 string (blob)
$fileContentBytes = get-content $certificateFilePath -Encoding Byte
[System.Convert]::ToBase64String($fileContentBytes) | Out-File "C:\Temp\$thumbprint.txt"
Write-Host "Your secure certificate blob is located at C:\Temp\$thumbprint.txt"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment