Skip to content

Commit

Permalink
Ping hosts to distinguish off-line cases
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tlhackque committed Jun 29, 2024
1 parent 7017dab commit ee68880
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion acme_token_check.1
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
.\" ========================================================================
.\"
.IX Title "ACME_TOKEN_CHECK 1"
.TH ACME_TOKEN_CHECK 1 22-Mar-2024 "" "Certificate Tools"
.TH ACME_TOKEN_CHECK 1 29-Jun-2024 "" "Certificate Tools"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
Expand Down
19 changes: 18 additions & 1 deletion ssl_status
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use warnings;
use strict;

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

Expand All @@ -24,6 +24,7 @@ use File::Spec;
use File::Temp;
use Getopt::Long( qw/GetOptionsFromString :config bundling/ );
use IO::Socket::IP;
use Net::Ping;
use POSIX( qw/mktime strftime/ );
use Sys::Hostname;
use Text::Abbrev;
Expand Down Expand Up @@ -53,6 +54,7 @@ sub formatVersion {
my $tmpdir = File::Spec->tmpdir || '.';

my $ostype = eval { require Perl::OSType; return Perl::OSType::os_type() } || 'Unix';
my $ping = Net::Ping->new( 'icmp', 5, 64 );
my $havepss;

# Duplicate / @loop detection
Expand Down Expand Up @@ -590,6 +592,21 @@ sub checkhost {
return analyzeChain( [ $host, $port ], $chain, $haskey, $opts, $at, $atl );
}

{
my( $h, $p ) = split( /:/, $host, 2 );
my @sts = $ping->ping( $h, 5 );
unless( @sts ) {
printf STDERR ( "Invalid host name '$h'\n" ) if( $debug );
missingcert( $host, $port, [''], 'OFFLINE', "Invalid name or address" );
return;
}
unless( $sts[0] ) {
printf STDERR ( "No ping response from '$h' ($sts[2])\n" ) if( $debug );
missingcert( $host, $port, [''], 'OFFLINE', "No ping response $sts[2]" );
return;
}
}

foreach my $type ( @{ $opts->{type} } ) {
my $cmd = "openssl s_client $opts->{CAcerts} $opts->{starttls}[0] -showcerts " .
"$opts->{tlsversion}[0] $type->[0] -connect $host";
Expand Down
2 changes: 1 addition & 1 deletion ssl_status.1
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
.\" ========================================================================
.\"
.IX Title "SSL_STATUS 1"
.TH SSL_STATUS 1 21-Mar-2024 "" "Certificate Tools"
.TH SSL_STATUS 1 29-Jun-2024 "" "Certificate Tools"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
Expand Down

0 comments on commit ee68880

Please sign in to comment.