Skip to content

Commit ba61d0e

Browse files
committed
Fix logic. As long as at least one cipher is configured, all is good.
1 parent e3bc27d commit ba61d0e

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

native/src/sslcontext.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,7 @@ TCN_IMPLEMENT_CALL(jboolean, SSLContext, setCipherSuite)(TCN_STDARGS, jlong ctx,
520520
jboolean rv = JNI_TRUE;
521521
int minProtoVer = 0;
522522
int maxProtoVer = 0;
523+
int ciphersSet = 0;
523524
#ifndef HAVE_EXPORT_CIPHERS
524525
size_t len;
525526
char *buf;
@@ -550,20 +551,20 @@ TCN_IMPLEMENT_CALL(jboolean, SSLContext, setCipherSuite)(TCN_STDARGS, jlong ctx,
550551
#endif
551552
/* OpenSSL will ignore any unknown cipher, but TLS 1.3 requires a call to SSL_CTX_set_ciphersuites */
552553
if (minProtoVer <= TLS1_2_VERSION) {
553-
if (!SSL_CTX_set_cipher_list(c->ctx, buf)) {
554-
char err[TCN_OPENSSL_ERROR_STRING_LENGTH];
555-
ERR_error_string_n(SSL_ERR_get(), err, TCN_OPENSSL_ERROR_STRING_LENGTH);
556-
tcn_Throw(e, "Unable to configure permitted SSL ciphers (%s)", err);
557-
rv = JNI_FALSE;
554+
if (SSL_CTX_set_cipher_list(c->ctx, buf)) {
555+
ciphersSet = 1;
558556
}
559557
}
560558
if (maxProtoVer >= TLS1_3_VERSION) {
561-
if (!SSL_CTX_set_ciphersuites(c->ctx, buf)) {
562-
char err[TCN_OPENSSL_ERROR_STRING_LENGTH];
563-
ERR_error_string_n(SSL_ERR_get(), err, TCN_OPENSSL_ERROR_STRING_LENGTH);
564-
tcn_Throw(e, "Unable to configure permitted SSL ciphers (%s)", err);
565-
rv = JNI_FALSE;
566-
}
559+
if (SSL_CTX_set_ciphersuites(c->ctx, buf)) {
560+
ciphersSet = 1;
561+
}
562+
}
563+
if (!ciphersSet) {
564+
char err[TCN_OPENSSL_ERROR_STRING_LENGTH];
565+
ERR_error_string_n(SSL_ERR_get(), err, TCN_OPENSSL_ERROR_STRING_LENGTH);
566+
tcn_Throw(e, "Unable to configure permitted SSL ciphers (%s)", err);
567+
rv = JNI_FALSE;
567568
}
568569
#ifndef HAVE_EXPORT_CIPHERS
569570
free(buf);

0 commit comments

Comments
 (0)