Created
November 19, 2009 04:10
-
-
Save waffle2k/238542 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/perl | |
# | |
# Attempt to match modulus of SSL CERTs/KEYs/CSRs | |
# | |
# author: pblair(AT)tucows(dot)com | |
# updated: Fri Aug 28 09:47:10 EDT 2009 | |
my( $KEY,$CRT,$CSR ); | |
for my $key ( @ARGV ){ | |
if ( $key =~ /crt$/i ){ | |
$CRT = $key; | |
} | |
if( $key =~ /key$/i ){ | |
$KEY = $key; | |
} | |
if( $key =~ /csr$/i ){ | |
$CSR = $key; | |
} | |
} | |
# Get the checksum | |
my $crtsum = ''; | |
my $keysum = ''; | |
my $csrsum = ''; | |
unless( $CRT eq '' ){ | |
$crtsum = `openssl x509 -noout -modulus -in $CRT | openssl md5`; | |
} | |
unless ( $KEY eq '' ){ | |
$keysum = `openssl rsa -noout -modulus -in $KEY | openssl md5`; | |
} | |
chomp( $crtsum ); | |
chomp( $keysum ); | |
print "CRT:[$CRT] : [$crtsum]\n"; | |
print "KEY:[$KEY] : [$keysum]\n"; | |
unless( $CSR eq '' ) { | |
$csrsum = `openssl req -noout -modulus -in $CSR | openssl md5`; | |
chomp( $csrsum ); | |
if( $csrsum eq $keysum ){ | |
print "CSR:[$CSR] : [$csrsum]\n"; | |
} | |
else{ | |
die("CSR does not match checksum test\n"); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment