Skip to content

Commit ee68880

Browse files
committed
Ping hosts to distinguish off-line cases
Off-line report can be caused by the service being down or by the host being unreachable. Pings each host before attempting to connect to the service.
1 parent 7017dab commit ee68880

3 files changed

Lines changed: 20 additions & 3 deletions

File tree

acme_token_check.1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
.\" ========================================================================
5656
.\"
5757
.IX Title "ACME_TOKEN_CHECK 1"
58-
.TH ACME_TOKEN_CHECK 1 22-Mar-2024 "" "Certificate Tools"
58+
.TH ACME_TOKEN_CHECK 1 29-Jun-2024 "" "Certificate Tools"
5959
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
6060
.\" way too many mistakes in technical documents.
6161
.if n .ad l

ssl_status

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use warnings;
44
use strict;
55

66
my $copyright = << 'COPYRIGHT';
7-
Copyright (C) 2021 - 2023 Timothe Litt <litt at acm.org>
7+
Copyright (C) 2021 - 2024 Timothe Litt <litt at acm.org>
88
Use --man for license information.
99
COPYRIGHT
1010

@@ -24,6 +24,7 @@ use File::Spec;
2424
use File::Temp;
2525
use Getopt::Long( qw/GetOptionsFromString :config bundling/ );
2626
use IO::Socket::IP;
27+
use Net::Ping;
2728
use POSIX( qw/mktime strftime/ );
2829
use Sys::Hostname;
2930
use Text::Abbrev;
@@ -53,6 +54,7 @@ sub formatVersion {
5354
my $tmpdir = File::Spec->tmpdir || '.';
5455

5556
my $ostype = eval { require Perl::OSType; return Perl::OSType::os_type() } || 'Unix';
57+
my $ping = Net::Ping->new( 'icmp', 5, 64 );
5658
my $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";

ssl_status.1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
.\" ========================================================================
5656
.\"
5757
.IX Title "SSL_STATUS 1"
58-
.TH SSL_STATUS 1 21-Mar-2024 "" "Certificate Tools"
58+
.TH SSL_STATUS 1 29-Jun-2024 "" "Certificate Tools"
5959
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
6060
.\" way too many mistakes in technical documents.
6161
.if n .ad l

0 commit comments

Comments
 (0)