Skip to content

Commit e75de5b

Browse files
authored
Generates a random salt only when (#4350)
RAND_priv_bytes is available, since OpenSSL 1.1.1
1 parent c23adb9 commit e75de5b

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/rdkafka.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8736,7 +8736,7 @@ typedef struct rd_kafka_UserScramCredentialAlteration_s
87368736
/**
87378737
* @brief Allocates a new UserScramCredentialUpsertion given its fields.
87388738
* If salt isn't given a 64 B salt is generated using OpenSSL
8739-
* RAND_bytes, if available.
8739+
* RAND_priv_bytes, if available.
87408740
*
87418741
* @param username The username (not empty).
87428742
* @param mechanism SASL/SCRAM mechanism.
@@ -8746,6 +8746,9 @@ typedef struct rd_kafka_UserScramCredentialAlteration_s
87468746
* @param salt Salt bytes (optional).
87478747
* @param salt_size Size of \p salt (optional).
87488748
*
8749+
* @remark A random salt is generated, when NULL, only if OpenSSL >= 1.1.1.
8750+
* Otherwise it's a required param.
8751+
*
87498752
* @return A newly created instance of rd_kafka_UserScramCredentialAlteration_t.
87508753
* Ownership belongs to the caller, use
87518754
* rd_kafka_UserScramCredentialAlteration_destroy to destroy.

src/rdkafka_admin.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5426,7 +5426,7 @@ rd_kafka_UserScramCredentialUpsertion_new(const char *username,
54265426
alteration->alteration.upsertion.salt =
54275427
rd_kafkap_bytes_new(salt, salt_size);
54285428
} else {
5429-
#if WITH_SSL
5429+
#if WITH_SSL && OPENSSL_VERSION_NUMBER >= 0x10101000L
54305430
unsigned char random_salt[64];
54315431
if (RAND_priv_bytes(random_salt, sizeof(random_salt)) == 1) {
54325432
alteration->alteration.upsertion.salt =

0 commit comments

Comments
 (0)