Skip to content

Commit fdf5a17

Browse files
committed
JNI: set options to filter cipher suites for TLS 1.3 protocol
1 parent b3daca0 commit fdf5a17

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

native/com_wolfssl_WolfSSL.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2029,6 +2029,7 @@ JNIEXPORT jstring JNICALL Java_com_wolfssl_WolfSSL_getAvailableCipherSuitesIana
20292029
byte cipherSuite0;
20302030
byte cipherSuite;
20312031
#endif
2032+
long noOpts = 0;
20322033
const char* cipherName = NULL;
20332034
const char* ianaName = NULL;
20342035
WOLFSSL_METHOD* method = NULL;
@@ -2067,11 +2068,16 @@ JNIEXPORT jstring JNICALL Java_com_wolfssl_WolfSSL_getAvailableCipherSuitesIana
20672068
#ifndef WOLFSSL_NO_TLS12
20682069
case 3:
20692070
method = wolfTLSv1_2_client_method();
2071+
noOpts = SSL_OP_NO_TLSv1_3;
20702072
break;
20712073
#endif
20722074
#ifdef WOLFSSL_TLS13
20732075
case 4:
20742076
method = wolfTLSv1_3_client_method();
2077+
noOpts = SSL_OP_NO_SSLv3 |
2078+
SSL_OP_NO_TLSv1 |
2079+
SSL_OP_NO_TLSv1_1 |
2080+
SSL_OP_NO_TLSv1_2;
20752081
break;
20762082
#endif
20772083
case 5:
@@ -2112,6 +2118,11 @@ JNIEXPORT jstring JNICALL Java_com_wolfssl_WolfSSL_getAvailableCipherSuitesIana
21122118
return NULL;
21132119
}
21142120

2121+
/* Filter cipher suites to only target protocol version */
2122+
if (noOpts != 0) {
2123+
wolfSSL_set_options(ssl, noOpts);
2124+
}
2125+
21152126
supportedCiphers = wolfSSL_get_ciphers_compat(ssl);
21162127
if (supportedCiphers == NULL) {
21172128
wolfSSL_free(ssl);

0 commit comments

Comments
 (0)