Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn user of expired cert #1411

Open
wants to merge 13 commits into
base: develop
Choose a base branch
from
1 change: 1 addition & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,7 @@ static void core_secondly()
logs[j].f = NULL;
}
}
verify_cert_expiry();
}
}
if (nowtm.tm_min == notify_users_at)
Expand Down
1 change: 1 addition & 0 deletions src/proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ int readtclprog(char *fname);

/* tls.c */
#ifdef TLS
void verify_cert_expiry();
michaelortmann marked this conversation as resolved.
Show resolved Hide resolved
int ssl_handshake(int, int, int, int, char *, IntFunc);
char *ssl_fpconv(char *in, char *out);
const char *ssl_getuid(int sock);
Expand Down
8 changes: 8 additions & 0 deletions src/tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,13 @@ static int ssl_seed(void)
return 0;
}

void verify_cert_expiry() {
michaelortmann marked this conversation as resolved.
Show resolved Hide resolved
X509 *x509;
if ((x509 = SSL_CTX_get0_certificate(ssl_ctx)) &&
(ASN1_TIME_cmp_time_t(X509_get0_notAfter(x509), time(NULL)) < 0))
putlog(LOG_MISC, "*", "WARNING: certificate expired: %s", tls_certfile);
}

/* Prepares and initializes SSL stuff
*
* Creates a context object, supporting SSLv2/v3 & TLSv1 protocols;
Expand Down Expand Up @@ -157,6 +164,7 @@ int ssl_init()
tls_certfile, ERR_error_string(ERR_get_error(), NULL));
fatal("Unable to load TLS certificate (ssl-certificate config setting)!", 0);
}
verify_cert_expiry();
if (SSL_CTX_use_PrivateKey_file(ssl_ctx, tls_keyfile, SSL_FILETYPE_PEM) != 1) {
putlog(LOG_MISC, "*", "ERROR: TLS: unable to load private key from %s: %s",
tls_keyfile, ERR_error_string(ERR_get_error(), NULL));
Expand Down