+nagios-plugins-local (0.3) unstable; urgency=low
+
+ * check_cert plugin now handles IPv6
+
+ -- Michael Howe <michael@michaelhowe.org> Fri, 17 Jun 2011 19:17:44 +0100
+
nagios-plugins-local (0.2) unstable; urgency=low
* Added check_ldaps_ip plugin
my $host = $uri->opaque();
$host =~ s/^\/+//;
my $port = undef;
-if ($host =~ s/:(\d+)//) {
+if( $host =~ m/\[([0-9A-F:]+)\](?::(\d+))?/i ){
+ # It's an IPv6 host, with an optional port
+ $host = $1;
+ if( $2 ){
+ $port = $2;
+ }
+ # If we've only got one : assume it's a port
+} elsif ( $host !~ m{:.*:} and $host =~ s/:(\d+)$//) {
$port = $1;
}
$host ||= 'localhost';
} elsif ($scheme eq 'https') {
$port ||= 443;
- $certdata = s_client("", "-connect $host:$port");
+ $certdata = s_client("", "--port $port $host");
} elsif ($scheme eq 'imaps') {
$port ||= 993;
- $certdata = s_client(". logout", "-connect $host:$port");
+ $certdata = s_client(". logout", "--port $port $host");
} elsif ($scheme eq 'ldaps') {
$port ||= 636;
- $certdata = s_client("", "-connect $host:$port");
+ $certdata = s_client("", "--port $port $host");
} elsif ($scheme eq 'smtp') {
$port ||= 25;
- $certdata = s_client("quit", "-starttls smtp -connect $host:$port");
+ $certdata = s_client("quit", "--starttls --port $port $host");
} elsif ($scheme eq 'smtps') {
$port ||= 465;
- $certdata = s_client("quit", "-connect $host:$port");
+ $certdata = s_client("quit", "--port $port $host");
} else {
usage(message => "unsupported scheme ($scheme)");
sub s_client {
my ($command, $arguments) = @_;
- return(parse_certificate(scalar(`/bin/echo $command | /usr/bin/openssl s_client $arguments 2>/dev/null | /usr/bin/openssl x509 -text 2>/dev/null`)));
+ return(parse_certificate(scalar(`/bin/echo $command | /usr/bin/gnutls-cli --insecure --print-cert $arguments 2>/dev/null | /usr/bin/openssl x509 -text 2>/dev/null`)));
}
sub read_file {