Check SSL altname too
authorJamie Cameron <jcameron@webmin.com>
Wed, 2 Feb 2011 21:57:36 +0000 (13:57 -0800)
committerJamie Cameron <jcameron@webmin.com>
Wed, 2 Feb 2011 21:57:36 +0000 (13:57 -0800)
status/CHANGELOG
status/sslcert-monitor.pl

index 08da6ab..3814ebb 100644 (file)
@@ -75,3 +75,5 @@ The Check File or Directory monitor can now use a pattern like /tmp/* to check s
 Added a monitor-level option to run a command if the monitor times out.
 ---- Changes since 1.520 ----
 Enhanced the free memory monitor to be able to check virtual memory as well.
+---- Changes since 1.530 ----
+Update the SSL certificate monitor to check alternate names as well when looking for hostname mismatches.
index 97e2cc9..093b44b 100755 (executable)
@@ -68,7 +68,25 @@ elsif ($_[0]->{'mismatch'} && $_[0]->{'url'} &&
        local $cn = $1;
        local $match = $1;
        $match =~ s/\*/\.\*/g;  # Make perl RE
-       if ($host !~ /^$match$/i) {
+       local @matches = ( $match );
+       if ($info =~ /Subject\s+Alternative\s+Name.*\r?\n\s*(.*)\n/) {
+               # Add UCC alternate names
+               local $alts = $1;
+               $alts =~ s/^\s+//;
+               $alts =~ s/\s+$//;
+               foreach my $a (split(/[, ]+/, $alts)) {
+                       if ($a =~ /^DNS:(\S+)/) {
+                               $match = $1;
+                               $match =~ s/\*/\.\*/g;  # Make perl RE
+                               push(@matches, $match);
+                               }
+                       }
+               }
+       local $ok = 0;
+       foreach $match (@matches) {
+               $ok++ if ($host =~ /^$match$/i);
+               }
+       if (!$ok) {
                $desc = &text('sslcert_ematch', "<tt>$host</tt>",
                              "<tt>$cn</tt>");
                }