Skip to content

Instantly share code, notes, and snippets.

@PlagueHO
Created September 10, 2016 11:36
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save PlagueHO/40c20a6cc143d3856c9c23da88843642 to your computer and use it in GitHub Desktop.
Save PlagueHO/40c20a6cc143d3856c9c23da88843642 to your computer and use it in GitHub Desktop.
Export a Base-64 x.509 certificate on Windows 7
$certificate = Get-ChildItem -Path Get-ChildItem -path Cert:\CurrentUser\My\D675AE3AE9F7B56348C17EE527F261CFCEA0FD13
$base64certificate = @"
-----BEGIN CERTIFICATE-----
$([Convert]::ToBase64String($certificate.Export('Cert'), [System.Base64FormattingOptions]::InsertLineBreaks)))
-----END CERTIFICATE-----
"@
Set-Content -Path "$ENV:USERPROFILE\Documents\MyCert.cer" -Value $base64certificate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment