Skip to content

Commit c09da16

Browse files
allow empty lists in SSL_CTX_set_ciphersuites
1 parent d09d423 commit c09da16

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

ssl/ssl_cipher.cc

+5-3
Original file line numberDiff line numberDiff line change
@@ -1336,9 +1336,11 @@ bool ssl_create_cipher_list(UniquePtr<SSLCipherPreferenceList> *out_cipher_list,
13361336

13371337
*out_cipher_list = std::move(pref_list);
13381338

1339-
// Configuring an empty cipher list is an error but still updates the
1340-
// output.
1341-
if (sk_SSL_CIPHER_num((*out_cipher_list)->ciphers.get()) == 0) {
1339+
// Configuring an empty cipher list is an error with |strict| but still
1340+
// updates the output. When otherwise, OpenSSL explicitly allows an empty
1341+
// list.
1342+
if ((strict || (*rule_str != '\0')) &&
1343+
sk_SSL_CIPHER_num((*out_cipher_list)->ciphers.get()) == 0) {
13421344
OPENSSL_PUT_ERROR(SSL, SSL_R_NO_CIPHER_MATCH);
13431345
return false;
13441346
}

ssl/ssl_test.cc

+11-6
Original file line numberDiff line numberDiff line change
@@ -548,8 +548,6 @@ static const char *kBadRules[] = {
548548
"[+RSA]",
549549
// Unknown directive.
550550
"@BOGUS",
551-
// Empty cipher lists error at SSL_CTX_set_cipher_list.
552-
"",
553551
"BOGUS",
554552
// COMPLEMENTOFDEFAULT is empty.
555553
"COMPLEMENTOFDEFAULT",
@@ -5757,12 +5755,19 @@ TEST(SSLTest, EmptyCipherList) {
57575755
// Initially, the cipher list is not empty.
57585756
EXPECT_NE(0u, sk_SSL_CIPHER_num(SSL_CTX_get_ciphers(ctx.get())));
57595757

5760-
// Configuring the empty cipher list fails.
5761-
EXPECT_FALSE(SSL_CTX_set_cipher_list(ctx.get(), ""));
5758+
// Configuring the empty cipher list with |SSL_CTX_set_cipher_list|
5759+
// succeeds.
5760+
EXPECT_TRUE(SSL_CTX_set_cipher_list(ctx.get(), ""));
5761+
5762+
// The cipher list is updated to empty.
5763+
EXPECT_EQ(0u, sk_SSL_CIPHER_num(SSL_CTX_get_ciphers(ctx.get())));
5764+
5765+
// Configuring the empty cipher list with |SSL_CTX_set_strict_cipher_list|
5766+
// fails.
5767+
EXPECT_FALSE(SSL_CTX_set_strict_cipher_list(ctx.get(), ""));
57625768
ERR_clear_error();
57635769

5764-
// Configuring the empty cipher list fails.
5765-
EXPECT_FALSE(SSL_CTX_set_ciphersuites(ctx.get(), ""));
5770+
EXPECT_FALSE(SSL_CTX_set_strict_cipher_list(ctx.get(), ""));
57665771
ERR_clear_error();
57675772

57685773
// But the cipher list is still updated to empty.

0 commit comments

Comments
 (0)