diff --git a/report-expiry.php b/report-expiry.php index 2e2e36b829726dc4c07102b8b832f13c1cc946f2..b38e5fde5180552a833887b295c4598095764ea3 100644 --- a/report-expiry.php +++ b/report-expiry.php @@ -26,7 +26,6 @@ function report( $exit = true ): void { 'CN', 'Expires', 'Days Left', - 'SAN', ], ]; @@ -48,24 +47,13 @@ function report( $exit = true ): void { 1 => $x509['subject']['CN'], 2 => date( 'Y-m-d H:i:s T', $x509['validTo_time_t'] ), 3 => (int) round( ( $x509['validTo_time_t'] - time() ) / 86400 ), - 4 => '', ]; - if ( ! $dir_includes_expired && $cert_data[3] <= 0 ) { + // Alert if any expire within the next 30 days. + if ( ! $dir_includes_expired && $cert_data[3] - 30 <= 0 ) { $dir_includes_expired = true; } - if ( isset( $x509['extensions']['subjectAltName'] ) ) { - $sans = explode( ',', $x509['extensions']['subjectAltName'] ); - - foreach ( $sans as $i => $san ) { - $san = explode( ':', $san ); - $sans[ $i ] = array_pop( $san ); - } - - $cert_data[4] = implode( ' ', $sans ); - } - $data[] = $cert_data; } @@ -74,6 +62,10 @@ function report( $exit = true ): void { $table->sort( 2 ); $table->display(); + if ( $dir_includes_expired ) { + echo "EXPIRING CERTIFICATES FOUND!\n"; + } + if ( $exit ) { exit( $dir_includes_expired ? 1 : 0 ); }