Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -9041,6 +9041,13 @@ then
ENABLED_ALPN=yes
fi

# Mosquitto calls SSL_CTX_set_alpn_protos() unconditionally for its
# bridge_alpn option, so the OpenSSL-compat ALPN surface has to be present.
if test "x$ENABLED_MOSQUITTO" = "xyes"
then
ENABLED_ALPN=yes
fi

if test "x$ENABLED_ALPN" = "xyes"
then
AM_CFLAGS="$AM_CFLAGS -DHAVE_TLS_EXTENSIONS -DHAVE_ALPN"
Expand Down
5 changes: 3 additions & 2 deletions src/ssl_api_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -2659,6 +2659,9 @@ int wolfSSL_set1_curves_list(WOLFSSL* ssl, const char* names)

#ifdef OPENSSL_EXTRA

#ifdef HAVE_ALPN
#ifndef NO_BIO

/* Set the ALPN protocol list, in wire format, on the context.
*
* @param [in] ctx SSL/TLS context object.
Expand Down Expand Up @@ -2712,8 +2715,6 @@ int wolfSSL_CTX_set_alpn_protos(WOLFSSL_CTX *ctx, const unsigned char *p,
}


#ifdef HAVE_ALPN
#ifndef NO_BIO
/* Convert a wire-format ALPN protocol list into a comma-separated string.
*
* The wire format is a sequence of entries, each a length byte followed by
Expand Down
6 changes: 5 additions & 1 deletion tests/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -18078,12 +18078,14 @@ static int test_wolfSSL_set_options(void)
#if defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL)
char appData[] = "extra msg";
#endif
#ifdef OPENSSL_EXTRA
#if defined(OPENSSL_EXTRA) && defined(HAVE_ALPN) && !defined(NO_BIO)
unsigned char protos[] = {
7, 't', 'l', 's', '/', '1', '.', '2',
8, 'h', 't', 't', 'p', '/', '1', '.', '1'
};
unsigned int len = sizeof(protos);
#endif
#ifdef OPENSSL_EXTRA
void *arg = (void *)TEST_ARG;
#endif

Expand Down Expand Up @@ -18168,12 +18170,14 @@ static int test_wolfSSL_set_options(void)
#ifdef OPENSSL_EXTRA
ExpectTrue(wolfSSL_set_msg_callback(ssl, msg_cb) == WOLFSSL_SUCCESS);
wolfSSL_set_msg_callback_arg(ssl, arg);
#if defined(HAVE_ALPN) && !defined(NO_BIO)
#ifdef WOLFSSL_ERROR_CODE_OPENSSL
ExpectTrue(wolfSSL_CTX_set_alpn_protos(ctx, protos, len) == 0);
#else
ExpectTrue(wolfSSL_CTX_set_alpn_protos(ctx, protos, len) == WOLFSSL_SUCCESS);
#endif
#endif
#endif

#if defined(WOLFSSL_NGINX) || defined(WOLFSSL_HAPROXY) || \
defined(WOLFSSL_MYSQL_COMPATIBLE) || defined(OPENSSL_ALL) || \
Expand Down
3 changes: 2 additions & 1 deletion tests/api/test_ssl_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,8 @@ int test_wolfSSL_CTX_set_servername_arg_inval_ext(void)
int test_wolfSSL_CTX_set_alpn_protos_inval_ext(void)
{
EXPECT_DECLS;
#if defined(OPENSSL_EXTRA) && !defined(NO_WOLFSSL_CLIENT) && !defined(NO_TLS)
#if defined(OPENSSL_EXTRA) && !defined(NO_WOLFSSL_CLIENT) && !defined(NO_TLS) \
&& defined(HAVE_ALPN) && !defined(NO_BIO)
WOLFSSL_CTX* ctx = NULL;
const unsigned char protos[] = { 2, 'h', '2' };
#if defined(WOLFSSL_ERROR_CODE_OPENSSL)
Expand Down
2 changes: 2 additions & 0 deletions wolfssl/ssl.h
Original file line number Diff line number Diff line change
Expand Up @@ -6008,10 +6008,12 @@ WOLFSSL_API int wolfSSL_CTX_set_msg_callback_arg(WOLFSSL_CTX *ctx, void* arg);
WOLFSSL_API int wolfSSL_set_msg_callback_arg(WOLFSSL *ssl, void* arg);
WOLFSSL_API unsigned long wolfSSL_ERR_peek_error_line_data(const char **file,
int *line, const char **data, int *flags);
#if defined(HAVE_ALPN) && !defined(NO_BIO)
WOLFSSL_API int wolfSSL_CTX_set_alpn_protos(WOLFSSL_CTX *ctx,
const unsigned char *protos, unsigned int protos_len);
WOLFSSL_API int wolfSSL_set_alpn_protos(WOLFSSL* ssl,
const unsigned char* protos, unsigned int protos_len);
#endif /* HAVE_ALPN && !NO_BIO */
WOLFSSL_API void *wolfSSL_OPENSSL_memdup(const void *data,
size_t siz, const char* file, int line);
WOLFSSL_API void wolfSSL_OPENSSL_cleanse(void *ptr, size_t len);
Expand Down
Loading