Last active
November 1, 2017 10:44
-
-
Save rgl/3055c9cedebeae7fd128aaa244757f14 to your computer and use it in GitHub Desktop.
export-windows-ca-certificates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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