Skip to content

Instantly share code, notes, and snippets.

@MudraR
Created July 17, 2025 12:48
Show Gist options
  • Select an option

  • Save MudraR/a0fe15afeb99d715b3a979a0bd12277b to your computer and use it in GitHub Desktop.

Select an option

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)
# 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