Skip to content

Allow export of whole certificate chainΒ #30

@TobiasSonndag

Description

@TobiasSonndag


For some certificates you need the whole chain to be exported (For example VMWare vCenter). I adapted your script and maybe you can add it here.

Solution taken from: https://stackoverflow.com/questions/33512409/automate-export-x509-certificate-w-chain-from-server-2008-r2-to-a-p7b-file-witho

New paramter
[Parameter(Mandatory = $False, ValueFromPipelineByPropertyName = $True, ParameterSetName='Export')] [switch]$ExportIncludeAllCerts

New code
$certs = New-Object Security.Cryptography.X509Certificates.X509Certificate2Collection if ($ExportIncludeAllCerts) { $chain = New-Object Security.Cryptography.X509Certificates.X509Chain $chain.ChainPolicy.RevocationMode = "NoCheck" [void]$chain.Build($cert) $chain.ChainElements | ForEach-Object {[void]$certs.Add($_.Certificate)} $chain.Reset() } else { [void]$certs.Add($Certificate) }

Thanks for your code, helped me a lot!

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions