Skip to content
Snippets Groups Projects
Commit b9ac146e authored by Erick Hitter's avatar Erick Hitter
Browse files

Merge branch 'updates' into 'master'

Alert for anything expiring within 30 days

See merge request !1
parents 92061175 a2531ba9
Branches master
No related tags found
1 merge request!1Alert for anything expiring within 30 days
...@@ -26,7 +26,6 @@ function report( $exit = true ): void { ...@@ -26,7 +26,6 @@ function report( $exit = true ): void {
'CN', 'CN',
'Expires', 'Expires',
'Days Left', 'Days Left',
'SAN',
], ],
]; ];
...@@ -48,24 +47,13 @@ function report( $exit = true ): void { ...@@ -48,24 +47,13 @@ function report( $exit = true ): void {
1 => $x509['subject']['CN'], 1 => $x509['subject']['CN'],
2 => date( 'Y-m-d H:i:s T', $x509['validTo_time_t'] ), 2 => date( 'Y-m-d H:i:s T', $x509['validTo_time_t'] ),
3 => (int) round( ( $x509['validTo_time_t'] - time() ) / 86400 ), 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; $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; $data[] = $cert_data;
} }
...@@ -74,6 +62,10 @@ function report( $exit = true ): void { ...@@ -74,6 +62,10 @@ function report( $exit = true ): void {
$table->sort( 2 ); $table->sort( 2 );
$table->display(); $table->display();
if ( $dir_includes_expired ) {
echo "EXPIRING CERTIFICATES FOUND!\n";
}
if ( $exit ) { if ( $exit ) {
exit( $dir_includes_expired ? 1 : 0 ); exit( $dir_includes_expired ? 1 : 0 );
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment