Skip to content

Instantly share code, notes, and snippets.

@CLCL
Created May 22, 2013 08:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CLCL/5625992 to your computer and use it in GitHub Desktop.
Save CLCL/5625992 to your computer and use it in GitHub Desktop.
指定したURLにSSLアクセスして、SSL通信が自己署名証明書(オレオレ証明書)かどうかざっくり調べる。
#!/usr/bin/perl
use strict;
use warnings;
use LWP::UserAgent;
my $url = 'https://www.verisign.co.jp/';
my $ua = LWP::UserAgent->new( ssl_opts => { verify_hostname => 0 } ) or die $!;
my $res = $ua->head( $url ) or die $!;
if ( $res->header("client-ssl-cert-issuer") eq $res->header("client-ssl-cert-subject") ) {
print "SSL証明書が自己署名証明書(オレオレ証明書)です。\n";
}
else {
print "SSL証明書が自己署名証明書ではないような気がします……\n";
}
exit;
__END__
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment