Skip to content

Commit

Permalink
Add some missing ifdefs
Browse files Browse the repository at this point in the history
  • Loading branch information
normanmaurer committed Sep 18, 2018
1 parent d8d9c8e commit 31e00da
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
6 changes: 6 additions & 0 deletions openssl-dynamic/src/main/c/ssl.c
Expand Up @@ -1578,11 +1578,17 @@ TCN_IMPLEMENT_CALL(jboolean, SSL, setCipherSuites)(TCN_STDARGS, jlong ssl,
if (!J2S(ciphers)) {
return JNI_FALSE;
}

#ifdef OPENSSL_NO_TLS1_3
rv = SSL_set_cipher_list(ssl_, J2S(ciphers)) == 0 ? JNI_FALSE : JNI_TRUE;
#else
if (tlsv13 == JNI_TRUE) {
rv = SSL_set_ciphersuites(ssl_, J2S(ciphers)) == 0 ? JNI_FALSE : JNI_TRUE;
} else {
rv = SSL_set_cipher_list(ssl_, J2S(ciphers)) == 0 ? JNI_FALSE : JNI_TRUE;
}
#endif

if (rv == JNI_FALSE) {
char err[256];
ERR_error_string(ERR_get_error(), err);
Expand Down
12 changes: 11 additions & 1 deletion openssl-dynamic/src/main/c/ssl_private.h
Expand Up @@ -133,9 +133,19 @@ extern const char* TCN_UNKNOWN_AUTH_METHOD;

#ifndef SSL_OP_NO_TLSv1_3
// TLSV1_3 is not really supported by the underlying OPENSSL version
#ifndef OPENSSL_NO_TLS1_3
#define OPENSSL_NO_TLS1_3
#endif // OPENSSL_NO_TLS1_3

#define SSL_OP_NO_TLSv1_3 0x20000000U
#endif
#endif // SSL_OP_NO_TLSv1_3

// BoringSSL does not support TLSv1.3 for now
#ifdef OPENSSL_IS_BORINGSSL
#ifndef OPENSSL_NO_TLS1_3
#define OPENSSL_NO_TLS1_3
#endif // OPENSSL_NO_TLS1_3
#endif // OPENSSL_IS_BORINGSSL

/* OpenSSL 1.0.2 compatibility */
#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
Expand Down
6 changes: 6 additions & 0 deletions openssl-dynamic/src/main/c/sslcontext.c
Expand Up @@ -441,11 +441,17 @@ TCN_IMPLEMENT_CALL(jboolean, SSLContext, setCipherSuite)(TCN_STDARGS, jlong ctx,
if (!J2S(ciphers)) {
return JNI_FALSE;
}

#ifdef OPENSSL_NO_TLS1_3
rv = SSL_CTX_set_cipher_list(c->ctx, J2S(ciphers)) == 0 ? JNI_FALSE : JNI_TRUE;
#else
if (tlsv13 == JNI_TRUE) {
rv = SSL_CTX_set_ciphersuites(c->ctx, J2S(ciphers)) == 0 ? JNI_FALSE : JNI_TRUE;
} else {
rv = SSL_CTX_set_cipher_list(c->ctx, J2S(ciphers)) == 0 ? JNI_FALSE : JNI_TRUE;
}
#endif

if (rv == JNI_FALSE) {
char err[256];
ERR_error_string(ERR_get_error(), err);
Expand Down

0 comments on commit 31e00da

Please sign in to comment.