#!/usr/bin/perl # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with this # work for additional information regarding copyright ownership. The ASF # licenses this file to You under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance with the # License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. # # (c) 2008 Dirk-Willem van Gulik / dirkx @ apache dot org, All Rights # reserved, Under the Apache 2.0 Software License. # # $Id: make.sh 171 2008-05-16 18:26:11Z dirkx $ # $|++; for my $fqdn (@ARGV) { $fqdn =~ s/[^a-z0-9\-\.]*//gi; $SIG{'ALRM'} = sub { `killall openssl`; return "Timeout"; }; alarm(3); open(STDIN,"true | openssl s_client -connect '$fqdn:443' -showcerts |") or return "Cannot connect"; my $e = 0; while() { alarm(0); if (m/^-----BEGIN CERTIFICATE-----/) { $e = 1; $z=''; }; $z .= $_ if $e; if (m/^-----END CERTIFICATE-----/) { $e = 0; open(FH,"echo '$z' | openssl x509 -noout -modulus |") or die $!; my $m = 0; while() { $m = $1 if m/Modulus=(.*)/; }; print "Checking $fqdn: "; print `(grep $m modu*.txt && echo Uh Oh)|| echo Perhaps ok` }; }; alarm(0); }