mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-30 22:43:08 +03:00
Add ALPN interface
This commit is contained in:
@ -860,6 +860,19 @@
|
|||||||
*/
|
*/
|
||||||
#define POLARSSL_SSL_PROTO_TLS1_2
|
#define POLARSSL_SSL_PROTO_TLS1_2
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \def POLARSSL_SSL_ALPN
|
||||||
|
*
|
||||||
|
* Enable support for Application Layer Protocol Negotiation.
|
||||||
|
* draft-ietf-tls-applayerprotoneg-05
|
||||||
|
*
|
||||||
|
* This is disabled by default in the 1.3.x line since it breaks ABI
|
||||||
|
* compatibility.
|
||||||
|
*
|
||||||
|
* Uncomment this macro to enable support for ALPN.
|
||||||
|
*/
|
||||||
|
#define POLARSSL_SSL_ALPN
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \def POLARSSL_SSL_SESSION_TICKETS
|
* \def POLARSSL_SSL_SESSION_TICKETS
|
||||||
*
|
*
|
||||||
|
@ -762,6 +762,14 @@ struct _ssl_context
|
|||||||
size_t hostname_len;
|
size_t hostname_len;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(POLARSSL_SSL_ALPN)
|
||||||
|
/*
|
||||||
|
* ALPN extension
|
||||||
|
*/
|
||||||
|
const char **alpn_list; /*!< ordered list of supported protocols */
|
||||||
|
const char *alpn_chosen; /*!< negotiated protocol */
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Secure renegotiation
|
* Secure renegotiation
|
||||||
*/
|
*/
|
||||||
@ -1232,6 +1240,28 @@ void ssl_set_sni( ssl_context *ssl,
|
|||||||
void *p_sni );
|
void *p_sni );
|
||||||
#endif /* POLARSSL_SSL_SERVER_NAME_INDICATION */
|
#endif /* POLARSSL_SSL_SERVER_NAME_INDICATION */
|
||||||
|
|
||||||
|
#if defined(POLARSSL_SSL_ALPN)
|
||||||
|
/**
|
||||||
|
* \brief Set the supported Application Layer Protocols.
|
||||||
|
*
|
||||||
|
* \param ssl SSL context
|
||||||
|
* \param protos NULL-terminated list of supported protocols,
|
||||||
|
* in decreasing preference order.
|
||||||
|
*/
|
||||||
|
void ssl_set_alpn_protocols( ssl_context *ssl, const char **protos );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Get the name of the negotiated Application Layer Protocol.
|
||||||
|
* This function should be called after the handshake is
|
||||||
|
* completed.
|
||||||
|
*
|
||||||
|
* \param ssl SSL context
|
||||||
|
*
|
||||||
|
* \return Protcol name, or NULL if no protocol was negotiated.
|
||||||
|
*/
|
||||||
|
const char *ssl_get_alpn_protocol( const ssl_context *ssl );
|
||||||
|
#endif /* POLARSSL_SSL_ALPN */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Set the maximum supported version sent from the client side
|
* \brief Set the maximum supported version sent from the client side
|
||||||
* and/or accepted at the server side
|
* and/or accepted at the server side
|
||||||
|
@ -3520,6 +3520,10 @@ int ssl_session_reset( ssl_context *ssl )
|
|||||||
ssl->session = NULL;
|
ssl->session = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(POLARSSL_SSL_ALPN)
|
||||||
|
ssl->alpn_chosen = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
if( ( ret = ssl_handshake_init( ssl ) ) != 0 )
|
if( ( ret = ssl_handshake_init( ssl ) ) != 0 )
|
||||||
return( ret );
|
return( ret );
|
||||||
|
|
||||||
@ -3914,6 +3918,18 @@ void ssl_set_sni( ssl_context *ssl,
|
|||||||
}
|
}
|
||||||
#endif /* POLARSSL_SSL_SERVER_NAME_INDICATION */
|
#endif /* POLARSSL_SSL_SERVER_NAME_INDICATION */
|
||||||
|
|
||||||
|
#if defined(POLARSSL_SSL_ALPN)
|
||||||
|
void ssl_set_alpn_protocols( ssl_context *ssl, const char **protos )
|
||||||
|
{
|
||||||
|
ssl->alpn_list = protos;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *ssl_get_alpn_protocol( const ssl_context *ssl )
|
||||||
|
{
|
||||||
|
return ssl->alpn_chosen;
|
||||||
|
}
|
||||||
|
#endif /* POLARSSL_SSL_ALPN */
|
||||||
|
|
||||||
void ssl_set_max_version( ssl_context *ssl, int major, int minor )
|
void ssl_set_max_version( ssl_context *ssl, int major, int minor )
|
||||||
{
|
{
|
||||||
if( major >= SSL_MIN_MAJOR_VERSION && major <= SSL_MAX_MAJOR_VERSION &&
|
if( major >= SSL_MIN_MAJOR_VERSION && major <= SSL_MAX_MAJOR_VERSION &&
|
||||||
|
Reference in New Issue
Block a user