Skip to content

Commit 2c7e1a8

Browse files
Guard wolfSSL_CTX_set_alpn_protos with HAVE_ALPN
1 parent 9ab8a4b commit 2c7e1a8

5 files changed

Lines changed: 19 additions & 4 deletions

File tree

configure.ac

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9041,6 +9041,13 @@ then
90419041
ENABLED_ALPN=yes
90429042
fi
90439043
9044+
# Mosquitto calls SSL_CTX_set_alpn_protos() unconditionally for its
9045+
# bridge_alpn option, so the OpenSSL-compat ALPN surface has to be present.
9046+
if test "x$ENABLED_MOSQUITTO" = "xyes"
9047+
then
9048+
ENABLED_ALPN=yes
9049+
fi
9050+
90449051
if test "x$ENABLED_ALPN" = "xyes"
90459052
then
90469053
AM_CFLAGS="$AM_CFLAGS -DHAVE_TLS_EXTENSIONS -DHAVE_ALPN"

src/ssl_api_ext.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2659,6 +2659,9 @@ int wolfSSL_set1_curves_list(WOLFSSL* ssl, const char* names)
26592659

26602660
#ifdef OPENSSL_EXTRA
26612661

2662+
#ifdef HAVE_ALPN
2663+
#ifndef NO_BIO
2664+
26622665
/* Set the ALPN protocol list, in wire format, on the context.
26632666
*
26642667
* @param [in] ctx SSL/TLS context object.
@@ -2712,8 +2715,6 @@ int wolfSSL_CTX_set_alpn_protos(WOLFSSL_CTX *ctx, const unsigned char *p,
27122715
}
27132716

27142717

2715-
#ifdef HAVE_ALPN
2716-
#ifndef NO_BIO
27172718
/* Convert a wire-format ALPN protocol list into a comma-separated string.
27182719
*
27192720
* The wire format is a sequence of entries, each a length byte followed by

tests/api.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18078,12 +18078,14 @@ static int test_wolfSSL_set_options(void)
1807818078
#if defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL)
1807918079
char appData[] = "extra msg";
1808018080
#endif
18081-
#ifdef OPENSSL_EXTRA
18081+
#if defined(OPENSSL_EXTRA) && defined(HAVE_ALPN) && !defined(NO_BIO)
1808218082
unsigned char protos[] = {
1808318083
7, 't', 'l', 's', '/', '1', '.', '2',
1808418084
8, 'h', 't', 't', 'p', '/', '1', '.', '1'
1808518085
};
1808618086
unsigned int len = sizeof(protos);
18087+
#endif
18088+
#ifdef OPENSSL_EXTRA
1808718089
void *arg = (void *)TEST_ARG;
1808818090
#endif
1808918091

@@ -18168,12 +18170,14 @@ static int test_wolfSSL_set_options(void)
1816818170
#ifdef OPENSSL_EXTRA
1816918171
ExpectTrue(wolfSSL_set_msg_callback(ssl, msg_cb) == WOLFSSL_SUCCESS);
1817018172
wolfSSL_set_msg_callback_arg(ssl, arg);
18173+
#if defined(HAVE_ALPN) && !defined(NO_BIO)
1817118174
#ifdef WOLFSSL_ERROR_CODE_OPENSSL
1817218175
ExpectTrue(wolfSSL_CTX_set_alpn_protos(ctx, protos, len) == 0);
1817318176
#else
1817418177
ExpectTrue(wolfSSL_CTX_set_alpn_protos(ctx, protos, len) == WOLFSSL_SUCCESS);
1817518178
#endif
1817618179
#endif
18180+
#endif
1817718181

1817818182
#if defined(WOLFSSL_NGINX) || defined(WOLFSSL_HAPROXY) || \
1817918183
defined(WOLFSSL_MYSQL_COMPATIBLE) || defined(OPENSSL_ALL) || \

tests/api/test_ssl_ext.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -947,7 +947,8 @@ int test_wolfSSL_CTX_set_servername_arg_inval_ext(void)
947947
int test_wolfSSL_CTX_set_alpn_protos_inval_ext(void)
948948
{
949949
EXPECT_DECLS;
950-
#if defined(OPENSSL_EXTRA) && !defined(NO_WOLFSSL_CLIENT) && !defined(NO_TLS)
950+
#if defined(OPENSSL_EXTRA) && !defined(NO_WOLFSSL_CLIENT) && !defined(NO_TLS) \
951+
&& defined(HAVE_ALPN) && !defined(NO_BIO)
951952
WOLFSSL_CTX* ctx = NULL;
952953
const unsigned char protos[] = { 2, 'h', '2' };
953954
#if defined(WOLFSSL_ERROR_CODE_OPENSSL)

wolfssl/ssl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6008,10 +6008,12 @@ WOLFSSL_API int wolfSSL_CTX_set_msg_callback_arg(WOLFSSL_CTX *ctx, void* arg);
60086008
WOLFSSL_API int wolfSSL_set_msg_callback_arg(WOLFSSL *ssl, void* arg);
60096009
WOLFSSL_API unsigned long wolfSSL_ERR_peek_error_line_data(const char **file,
60106010
int *line, const char **data, int *flags);
6011+
#if defined(HAVE_ALPN) && !defined(NO_BIO)
60116012
WOLFSSL_API int wolfSSL_CTX_set_alpn_protos(WOLFSSL_CTX *ctx,
60126013
const unsigned char *protos, unsigned int protos_len);
60136014
WOLFSSL_API int wolfSSL_set_alpn_protos(WOLFSSL* ssl,
60146015
const unsigned char* protos, unsigned int protos_len);
6016+
#endif /* HAVE_ALPN && !NO_BIO */
60156017
WOLFSSL_API void *wolfSSL_OPENSSL_memdup(const void *data,
60166018
size_t siz, const char* file, int line);
60176019
WOLFSSL_API void wolfSSL_OPENSSL_cleanse(void *ptr, size_t len);

0 commit comments

Comments
 (0)