Skip to content

Commit 642716a

Browse files
niedbalskiJorge Niedbalski
and
Jorge Niedbalski
authored
tls: include X509 error string when verify result is not x509_V_OK. (#9527)
Add the X509_verify_cert_error_string to the log message when SSL verification result != X509_V_OK. Signed-off-by: Jorge Niedbalski <[email protected]> Co-authored-by: Jorge Niedbalski <[email protected]>
1 parent e7c3e93 commit 642716a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/tls/openssl.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,7 @@ static int tls_net_handshake(struct flb_tls *tls,
684684
char err_buf[256];
685685
struct tls_session *session = ptr_session;
686686
struct tls_context *ctx;
687+
const char *x509_err;
687688

688689
ctx = session->parent;
689690
pthread_mutex_lock(&ctx->mutex);
@@ -743,8 +744,9 @@ static int tls_net_handshake(struct flb_tls *tls,
743744
if (ret == 0) {
744745
ssl_code = SSL_get_verify_result(session->ssl);
745746
if (ssl_code != X509_V_OK) {
746-
flb_error("[tls] error: unexpected EOF with reason: %s",
747-
ERR_reason_error_string(ERR_get_error()));
747+
/* Refer to: https://x509errors.org/ */
748+
x509_err = X509_verify_cert_error_string(ssl_code);
749+
flb_error("[tls] certificate verification failed, reason: %s (X509 code: %ld)", x509_err, ssl_code);
748750
}
749751
else {
750752
flb_error("[tls] error: unexpected EOF");

0 commit comments

Comments
 (0)