Skip to content

Commit

Permalink
print exp cert when owner logged in and daily
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Ortmann committed Oct 2, 2023
1 parent e73b4cf commit c7fb9e4
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/dccutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@ void dcc_chatter(int idx)
dcc[idx].u.chat->channel = 234567;
j = dcc[idx].sock;
strcpy(dcc[idx].u.chat->con_chan, "***");
if (is_owner(dcc[idx].user))
verify_cert_expiry(idx);
check_tcl_chon(dcc[idx].nick, dcc[idx].sock);
/* Still there? */
if ((idx >= dcc_total) || (dcc[idx].sock != j))
Expand Down
2 changes: 1 addition & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,6 @@ static void core_secondly()
logs[j].f = NULL;
}
}
verify_cert_expiry();
}
}
if (nowtm.tm_min == notify_users_at)
Expand All @@ -706,6 +705,7 @@ static void core_secondly()
movefile(logs[i].filename, s);
}
}
verify_cert_expiry(0);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ int readtclprog(char *fname);

/* tls.c */
#ifdef TLS
void verify_cert_expiry(void);
void verify_cert_expiry(int);
int ssl_handshake(int, int, int, int, char *, IntFunc);
char *ssl_fpconv(char *in, char *out);
const char *ssl_getuid(int sock);
Expand Down
12 changes: 8 additions & 4 deletions src/tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,15 @@ static int ssl_seed(void)
return 0;
}

void verify_cert_expiry(void) {
void verify_cert_expiry(int idx) {
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);
(ASN1_TIME_cmp_time_t(X509_get0_notAfter(x509), time(NULL)) < 0)) {
if (idx)
dprintf(idx,"WARNING: certificate expired: %s\n", tls_certfile);
else
putlog(LOG_MISC, "*", "WARNING: certificate expired: %s", tls_certfile);
}
}

/* Prepares and initializes SSL stuff
Expand Down Expand Up @@ -164,7 +168,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();
verify_cert_expiry(0);
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

0 comments on commit c7fb9e4

Please sign in to comment.