Skip to content

Commit 09300b8

Browse files
committed
Add "brief" report format for ssl_status
Make the ssl_status reports a bit easier to read by suppressing duplicate hostnames. (These occur for dual-certificate hosts when the certificates expire on the same day.) The "brief" format is the default, but it may change based on experience. The --nobrief option delivers the abbreviated report format, which is more suitable for scripts.
1 parent 6802c80 commit 09300b8

3 files changed

Lines changed: 53 additions & 7 deletions

File tree

ssl_status

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ sub days {
189189

190190
# Option values
191191
my( @contents, $debug, $email_from, @email_to, $warn, $inifile,
192-
@smtp_servers, $smtp_user, $smtp_password, $smtp_ssl_mode, $logo,
192+
@smtp_servers, $smtp_user, $smtp_password, $smtp_ssl_mode, $logo, $brief,
193193
$help, $man, $version, );
194194

195195
# Execute command & print unexpected errors
@@ -678,6 +678,7 @@ sub genTextReport {
678678
( $col->{last} ? "\n" : ' ' ) );
679679
}
680680

681+
my $phost;
681682
foreach my $cert ( @$data ) {
682683
foreach my $col ( @$columns ) {
683684
my $from = $col->{from};
@@ -688,6 +689,14 @@ sub genTextReport {
688689
$val = $cert->{$from};
689690
}
690691
$val = 'Unknown' unless( defined $val );
692+
if( $brief && $col->{name} eq 'Host' ) {
693+
if( $phost && $phost eq $val ) {
694+
$val = '';
695+
} else {
696+
$phost = $val;
697+
698+
}
699+
}
691700
if( $col->{wrap} && length $val > $col->{width} ) {
692701
print $out ( "$val\n" );
693702
my $wp = 0;
@@ -722,6 +731,7 @@ sub genHtmlReport {
722731
printf $out ( "<th>%s</th>", $col->{name} );
723732
}
724733
printf $out ( "</tr>$nl</thead>$nl<tbody>$nl" );
734+
my $phost;
725735
foreach my $cert ( @$data ) {
726736
printf $out ( "<tr>" );
727737
foreach my $col ( @$columns ) {
@@ -733,6 +743,14 @@ sub genHtmlReport {
733743
$val = $cert->{$from};
734744
}
735745
$val = 'Unknown' unless( defined $val );
746+
if( $brief && $col->{name} eq 'Host' ) {
747+
if( $phost && $phost eq $val ) {
748+
$val = '&nbsp;';
749+
} else {
750+
$phost = $val;
751+
752+
}
753+
}
736754
my $class = $col->{class} || '';
737755
$class .= ' right' if( $col->{j} );
738756
if( exists $col->{match} ) {
@@ -1260,6 +1278,7 @@ sub smtpfail {
12601278
return \%vals;
12611279
}
12621280
@globaloptions = ( "debug|d!" => \$debug,
1281+
"brief!" => \$brief,
12631282
"email-from|e-mail-from=s" => \$email_from,
12641283
"no-email-from|noemail-from" => sub { undef $email_from },
12651284
"email-to|e-mail-to=s" => \@email_to,
@@ -1301,7 +1320,8 @@ if( $version ) {
13011320
printf( "%s version %s\n%s", $prog, formatVersion( $VERSION ), $copyright );
13021321
exit;
13031322
}
1304-
$warn = 1 unless( defined $warn );
1323+
$warn = 1 unless( defined $warn );
1324+
$brief = 1 unless( defined $brief );
13051325

13061326
if( $inifile && defined $smtp_password ) {
13071327
eval q{
@@ -1642,6 +1662,7 @@ ssl_status - check the certificate status for hosts and files
16421662
ssl_status [options] [host[:port] ...] [file:FILE] [@file...]
16431663
16441664
Options:
1665+
--brief Abbreviate report
16451666
--CAfile=file Specify bundle file of trusted CA certificates for verification
16461667
--CApath=dir Specify a hashed directory containing trusted CA certificates for verification.
16471668
--email-to=list Specify email address(es) to receive reports
@@ -1679,7 +1700,15 @@ files.
16791700
16801701
=over 8
16811702
1682-
=item B<--CAfile>=I<file> B<--no-CAfile> I<@file>
1703+
=item B<--brief> B<--no-brief>
1704+
1705+
Abbreviate report contents for easier reading (default). Use B<--no-brief> if output will be parsed by a script.
1706+
1707+
Currently, B<--brief> avoids repeating the hostname in adjacent rows, but this may be changed.
1708+
Note that if a host's certificates expire on different dates, data from other hosts may prevent
1709+
abbreviation.
1710+
1711+
=item B<--CAfile>=I<file> B<--no-CAfile>
16831712
16841713
Specify a file containing one or more trusted CA certificates to verify the host's certificate chain.
16851714

ssl_status.1

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@
129129
.\" ========================================================================
130130
.\"
131131
.IX Title "SSL_STATUS 1"
132-
.TH SSL_STATUS 1 "14-Nov-2021 08:48:02" "" "Certificate Tools"
132+
.TH SSL_STATUS 1 "01-Dec-2021 07:17:17" "" "Certificate Tools"
133133
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
134134
.\" way too many mistakes in technical documents.
135135
.if n .ad l
@@ -143,6 +143,7 @@ ssl_status [options] [host[:port] ...] [file:FILE] [@file...]
143143
.PP
144144
.Vb 10
145145
\& Options:
146+
\& \-\-Brief Abbreviate report
146147
\& \-\-CAfile=file Specify bundle file of trusted CA certificates for verification
147148
\& \-\-CApath=dir Specify a hashed directory containing trusted CA certificates for verification.
148149
\& \-\-email\-to=list Specify email address(es) to receive reports
@@ -177,8 +178,15 @@ When used in an indrect command file, they affect only systems mentioned on the
177178
continued) line on which they occur. When used on the command line or initialization file,
178179
they affect systems listed there, and also serve as defaults for systems lised in indirect command
179180
files.
180-
.IP "\fB\-\-CAfile\fR=\fIfile\fR \fB\-\-no\-CAfile\fR \fI\f(CI@file\fI\fR" 8
181-
.IX Item "--CAfile=file --no-CAfile @file"
181+
.IP "\fB\-\-brief\fR \fB\-\-no\-brief\fR" 8
182+
.IX Item "--brief --no-brief"
183+
Abbreviate report contents for easier reading (default). Use \fB\-\-no\-brief\fR if output will be parsed by a script.
184+
.Sp
185+
Currently, \fB\-\-brief\fR avoids repeating the hostname in adjacent rows, but this may be changed.
186+
Note that if a host's certificates expire on different dates, data from other hosts may prevent
187+
abbreviation.
188+
.IP "\fB\-\-CAfile\fR=\fIfile\fR \fB\-\-no\-CAfile\fR" 8
189+
.IX Item "--CAfile=file --no-CAfile"
182190
Specify a file containing one or more trusted \s-1CA\s0 certificates to verify the host's certificate chain.
183191
.Sp
184192
If not specified, the environment variables \s-1SSL_CERT_FILE\s0 and \s-1CURL_CA_BUNDLE\s0 will be tried, and if neither of them is set, OpenSSL's default will be used.

ssl_status.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ ssl\_status - check the certificate status for hosts and files
77
ssl\_status \[options\] \[host\[:port\] ...\] \[file:FILE\] \[@file...\]
88

99
Options:
10+
--Brief Abbreviate report
1011
--CAfile=file Specify bundle file of trusted CA certificates for verification
1112
--CApath=dir Specify a hashed directory containing trusted CA certificates for verification.
1213
--email-to=list Specify email address(es) to receive reports
@@ -42,7 +43,15 @@ continued) line on which they occur. When used on the command line or initializ
4243
they affect systems listed there, and also serve as defaults for systems lised in indirect command
4344
files.
4445

45-
- **--CAfile**=_file_ **--no-CAfile** _@file_
46+
- **--brief** **--no-brief**
47+
48+
Abbreviate report contents for easier reading (default). Use **--no-brief** if output will be parsed by a script.
49+
50+
Currently, **--brief** avoids repeating the hostname in adjacent rows, but this may be changed.
51+
Note that if a host's certificates expire on different dates, data from other hosts may prevent
52+
abbreviation.
53+
54+
- **--CAfile**=_file_ **--no-CAfile**
4655

4756
Specify a file containing one or more trusted CA certificates to verify the host's certificate chain.
4857

0 commit comments

Comments
 (0)