Skip to content

Instantly share code, notes, and snippets.

@Brycey92
Last active September 5, 2019 05:14
Show Gist options
  • Save Brycey92/383c63079b5b9ca5e3cdaaa46be54b96 to your computer and use it in GitHub Desktop.
Save Brycey92/383c63079b5b9ca5e3cdaaa46be54b96 to your computer and use it in GitHub Desktop.
Meant to be used with the Certify the Web certificate manager as the post-request script. Fill in the CAPITALIZED fields before using.
param($result)
$tempCertPath = "temp.pem"
$certPath = "PATH TO SAVE A MASTER COPY OF YOUR ENCRYPTED CERTIFICATE.pfx"
$destinationPaths = @()
#You can repeat the line below as many times as you need, once for each destination certificate path
$destinationPaths += "PATH TO COPY YOUR CERTIFICATE TO.pfx"
$pass = "YOUR PASSWORD"
$alias = "YOUR CERTIFICATE ALIAS"
if ($result.IsSuccess) {
openssl pkcs12 -in $result.ManagedItem.CertificatePath -out $tempCertPath -passin `"pass:`" -nodes
openssl pkcs12 -export -in $tempCertPath -out $certPath -passout pass:$pass -name $alias
Remove-Item $tempCertPath
foreach($destinationPath in $destinationPaths) {
Copy-Item -Path $certPath -Destination $destinationPath -Force
}
Write-Output "Deployment complete."
} else {
Write-Error "Deployment failed."
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment