@@ -4,7 +4,7 @@ use warnings;
44use strict;
55
66my $copyright = << 'COPYRIGHT' ;
7- Copyright (C) 2021 - 2023 Timothe Litt <litt at acm.org>
7+ Copyright (C) 2021 - 2024 Timothe Litt <litt at acm.org>
88Use --man for license information.
99COPYRIGHT
1010
@@ -24,6 +24,7 @@ use File::Spec;
2424use File::Temp;
2525use Getopt::Long( qw/ GetOptionsFromString :config bundling/ );
2626use IO::Socket::IP;
27+ use Net::Ping;
2728use POSIX( qw/ mktime strftime/ );
2829use Sys::Hostname;
2930use Text::Abbrev;
@@ -53,6 +54,7 @@ sub formatVersion {
5354my $tmpdir = File::Spec-> tmpdir || ' .' ;
5455
5556my $ostype = eval { require Perl::OSType; return Perl::OSType::os_type() } || ' Unix' ;
57+ my $ping = Net::Ping-> new( ' icmp' , 5, 64 );
5658my $havepss ;
5759
5860# Duplicate / @loop detection
@@ -590,6 +592,21 @@ sub checkhost {
590592 return analyzeChain( [ $host , $port ], $chain , $haskey , $opts , $at , $atl );
591593 }
592594
595+ {
596+ my ( $h , $p ) = split ( / :/ , $host , 2 );
597+ my @sts = $ping -> ping( $h , 5 );
598+ unless ( @sts ) {
599+ printf STDERR ( " Invalid host name '$h '\n " ) if ( $debug );
600+ missingcert( $host , $port , [' ' ], ' OFFLINE' , " Invalid name or address" );
601+ return ;
602+ }
603+ unless ( $sts [0] ) {
604+ printf STDERR ( " No ping response from '$h ' ($sts [2])\n " ) if ( $debug );
605+ missingcert( $host , $port , [' ' ], ' OFFLINE' , " No ping response $sts [2]" );
606+ return ;
607+ }
608+ }
609+
593610 foreach my $type ( @{ $opts -> {type } } ) {
594611 my $cmd = " openssl s_client $opts ->{CAcerts} $opts ->{starttls}[0] -showcerts " .
595612 " $opts ->{tlsversion}[0] $type ->[0] -connect $host " ;
0 commit comments