Forum Discussion
Stover
Jun 03, 2025Copper Contributor
Differences with X509Certificate2 between Powershell and PWSH Core (Windows)
Hi all,
I wrote some code that loads a certificate from a crt file and it works so far.
But with PWSH (7.5.1) some properties (like DnsNameList) are empty.
With Windows Powershell the properties are filled.
This is true, even when using static LoadCertificateFromFile class under PWSH.
(Otherwise I load the certificate with [ X509Certificate2]::new( thebytes ))
The validity of the certificate makes no difference so far.
It would be nice if anyone has a suggestion how I can work around that issue.
THX in advance and best regards!
2 Replies
Sort By
- Andres-BohrenSteel Contributor
Hi Stover
Can you check this Code
$Cert = Get-ChildItem Cert:\LocalMachine\My\ | where {$_.Thumbprint -eq "99A90D03DDAC94080B2B94B4262A850B41C8F030"} $Cert | select subject,NotBefore, notafter, Issuer, Thumbprint,HasPrivateKey, @{name='Subject Alternative Name';expression={($_.Extensions | Where-Object {$_.Oid.FriendlyName -eq "Subject Alternative Name"}).format($true)}}
Kind Regards
Andres
- Andres-BohrenSteel Contributor
Stover
Did you test it? Any Feedback?