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

logsrvd,plugins/sudoers: add debug log on TLS verification error #375

Merged
merged 1 commit into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion logsrvd/logsrvd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1259,15 +1259,24 @@ verify_peer_identity(int preverify_ok, X509_STORE_CTX *ctx)
X509 *peer_cert;
debug_decl(verify_peer_identity, SUDO_DEBUG_UTIL);

current_cert = X509_STORE_CTX_get_current_cert(ctx);

/* if pre-verification of the cert failed, just propagate that result back */
if (preverify_ok != 1) {
int err = X509_STORE_CTX_get_error(ctx);
char current_cert_name[256] = "";
if (current_cert != NULL)
X509_NAME_oneline(X509_get_subject_name(current_cert), current_cert_name, sizeof(current_cert_name));

sudo_debug_printf(SUDO_DEBUG_INFO|SUDO_DEBUG_LINENO,
"TLS verification failed for cert '%s': '%d:%s'", current_cert_name,
err, X509_verify_cert_error_string(err));
debug_return_int(0);
}

/* since this callback is called for each cert in the chain,
* check that current cert is the peer's certificate
*/
current_cert = X509_STORE_CTX_get_current_cert(ctx);
peer_cert = X509_STORE_CTX_get0_cert(ctx);

if (current_cert != peer_cert) {
Expand Down
11 changes: 10 additions & 1 deletion logsrvd/tls_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,25 @@ verify_peer_identity(int preverify_ok, X509_STORE_CTX *ctx)
X509 *peer_cert;
debug_decl(verify_peer_identity, SUDO_DEBUG_UTIL);

current_cert = X509_STORE_CTX_get_current_cert(ctx);

/* if pre-verification of the cert failed, just propagate that result back */
if (preverify_ok != 1) {
int err = X509_STORE_CTX_get_error(ctx);
char current_cert_name[256] = "";
if (current_cert != NULL)
X509_NAME_oneline(X509_get_subject_name(current_cert), current_cert_name, sizeof(current_cert_name));

sudo_debug_printf(SUDO_DEBUG_INFO|SUDO_DEBUG_LINENO,
"TLS verification failed for cert '%s': '%d:%s'", current_cert_name,
err, X509_verify_cert_error_string(err));
debug_return_int(0);
}

/*
* Since this callback is called for each cert in the chain,
* check that current cert is the peer's certificate
*/
current_cert = X509_STORE_CTX_get_current_cert(ctx);
peer_cert = X509_STORE_CTX_get0_cert(ctx);
if (current_cert != peer_cert) {
debug_return_int(1);
Expand Down
11 changes: 10 additions & 1 deletion plugins/sudoers/log_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,24 @@ verify_peer_identity(int preverify_ok, X509_STORE_CTX *ctx)
X509 *peer_cert;
debug_decl(verify_peer_identity, SUDOERS_DEBUG_UTIL);

current_cert = X509_STORE_CTX_get_current_cert(ctx);

/* if pre-verification of the cert failed, just propagate that result back */
if (preverify_ok != 1) {
int err = X509_STORE_CTX_get_error(ctx);
char current_cert_name[256] = "";
if (current_cert != NULL)
X509_NAME_oneline(X509_get_subject_name(current_cert), current_cert_name, sizeof(current_cert_name));

sudo_debug_printf(SUDO_DEBUG_INFO|SUDO_DEBUG_LINENO,
"TLS verification failed for cert '%s': '%d:%s'", current_cert_name,
err, X509_verify_cert_error_string(err));
debug_return_int(0);
}

/* since this callback is called for each cert in the chain,
* check that current cert is the peer's certificate
*/
current_cert = X509_STORE_CTX_get_current_cert(ctx);
peer_cert = X509_STORE_CTX_get0_cert(ctx);

if (current_cert != peer_cert) {
Expand Down
Loading