Skip to content

Instantly share code, notes, and snippets.

@rgl
Last active November 1, 2017 10:44
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 rgl/3055c9cedebeae7fd128aaa244757f14 to your computer and use it in GitHub Desktop.
Save rgl/3055c9cedebeae7fd128aaa244757f14 to your computer and use it in GitHub Desktop.
export-windows-ca-certificates
# dump all the windows trusted roots into a ca file.
$pems = New-Object System.Text.StringBuilder
Get-ChildItem Cert:\LocalMachine\Root | ForEach-Object {
# $_ is-a System.Security.Cryptography.X509Certificates.X509Certificate2
Write-Host "Exporting the $($_.Issuer) certificate..."
[void]$pems.AppendLine('-----BEGIN CERTIFICATE-----')
[void]$pems.AppendLine(
[Convert]::ToBase64String(
$_.Export('Cert'),
'InsertLineBreaks'));
[void]$pems.AppendLine("-----END CERTIFICATE-----");
}
Set-Content `
-Encoding Ascii `
C:\ProgramData\ca-certificates.crt `
$pems.ToString()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment