Skip to content

Commit d86b001

Browse files
authored
Fix to avoid issuing a warning in case server requests a certificate and client is using SASL authentication only (#4936)
without any client certificate set
1 parent 4f8fcfc commit d86b001

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/rdkafka_ssl.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,6 +1076,15 @@ static int rd_kafka_ssl_cert_callback(SSL *ssl, void *arg) {
10761076
X509 *cert;
10771077
int i;
10781078

1079+
/* Get client cert from SSL connection */
1080+
cert = SSL_get_certificate(ssl);
1081+
if (cert == NULL) {
1082+
/* If there's no client certificate,
1083+
* skip certificate issuer verification and
1084+
* avoid logging a warning. */
1085+
return 1;
1086+
}
1087+
10791088
/* Get the accepted client CA list from the SSL connection, this
10801089
* comes from the `certificate_authorities` field. */
10811090
ca_list = SSL_get_client_CA_list(ssl);
@@ -1088,10 +1097,7 @@ static int rd_kafka_ssl_cert_callback(SSL *ssl, void *arg) {
10881097
return 1;
10891098
}
10901099

1091-
/* Get client cert from SSL connection */
1092-
cert = SSL_get_certificate(ssl);
1093-
1094-
if (cert != NULL && rd_kafka_ssl_cert_issuer_match(ca_list, cert)) {
1100+
if (rd_kafka_ssl_cert_issuer_match(ca_list, cert)) {
10951101
/* A match is found, use the certificate. */
10961102
return 1;
10971103
}

0 commit comments

Comments
 (0)