Created
July 17, 2025 12:48
-
-
Save MudraR/a0fe15afeb99d715b3a979a0bd12277b to your computer and use it in GitHub Desktop.
Matching renewed certificates (from GoDaddy) by public key (for when CN is the same)
This file contains hidden or 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
| # Get all .crt certificates, excluding those with 'bundle' in the name | |
| $crtCerts = Get-ChildItem -Path . -Recurse -Filter *.crt | Where-Object { $_.Name -notmatch 'bundle' } | ForEach-Object { | |
| $cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2($_.FullName) | |
| [PSCustomObject]@{ | |
| FileName = $_.Name | |
| Subject = $cert.Subject | |
| SerialNumber = $cert.SerialNumber | |
| Thumbprint = $cert.Thumbprint | |
| PublicKey = $cert.GetPublicKeyString() | |
| } | |
| } | |
| # Get all .cer certificates | |
| $cerCerts = Get-ChildItem -Path . -Recurse -Filter *.cer | ForEach-Object { | |
| $cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2($_.FullName) | |
| [PSCustomObject]@{ | |
| FileName = $_.Name | |
| Subject = $cert.Subject | |
| SerialNumber = $cert.SerialNumber | |
| Thumbprint = $cert.Thumbprint | |
| PublicKey = $cert.GetPublicKeyString() | |
| } | |
| } | |
| # Compare the public keys of .crt and .cer certificates | |
| foreach ($crtCert in $crtCerts) { | |
| foreach ($cerCert in $cerCerts) { | |
| if ($crtCert.PublicKey -eq $cerCert.PublicKey) { | |
| [PSCustomObject]@{ | |
| GoDaddyCert = $crtCert.FileName | |
| OctoCert = $cerCert.FileName | |
| PublicKey = $crtCert.PublicKey | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment