Skip to content

Commit 64811ff

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

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

native/com_wolfssl_WolfSSL.c

Lines changed: 13 additions & 1 deletion
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:
@@ -2095,7 +2101,8 @@ JNIEXPORT jstring JNICALL Java_com_wolfssl_WolfSSL_getAvailableCipherSuitesIana
20952101
#endif
20962102
#endif
20972103
default:
2098-
printf("Input protocol version invalid: %d\n", protocolVersion);
2104+
printf("Input protocol version invalid: %d\n",
2105+
protocolVersion);
20992106
return NULL;
21002107
}
21012108

@@ -2112,6 +2119,11 @@ JNIEXPORT jstring JNICALL Java_com_wolfssl_WolfSSL_getAvailableCipherSuitesIana
21122119
return NULL;
21132120
}
21142121

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

0 commit comments

Comments
 (0)