From 0c9f7271a91be54aec0bfec5874d7ecc7abcc005 Mon Sep 17 00:00:00 2001 From: Stephen Bird Date: Mon, 15 Oct 2018 14:46:52 -0700 Subject: [PATCH] Add checks to for CONFIG_MBEDTLS_SSL_ALPN Merges https://github.com/espressif/esp-idf/pull/2569 --- components/aws_iot/port/network_mbedtls_wrapper.c | 2 ++ components/esp-tls/esp_tls.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/components/aws_iot/port/network_mbedtls_wrapper.c b/components/aws_iot/port/network_mbedtls_wrapper.c index 6da6d5dad0..a9f6e5e18e 100644 --- a/components/aws_iot/port/network_mbedtls_wrapper.c +++ b/components/aws_iot/port/network_mbedtls_wrapper.c @@ -236,6 +236,7 @@ IoT_Error_t iot_tls_connect(Network *pNetwork, TLSConnectParams *params) { mbedtls_ssl_conf_read_timeout(&(tlsDataParams->conf), pNetwork->tlsConnectParams.timeout_ms); +#ifdef CONFIG_MBEDTLS_SSL_ALPN /* Use the AWS IoT ALPN extension for MQTT, if port 443 is requested */ if (pNetwork->tlsConnectParams.DestinationPort == 443) { const char *alpnProtocols[] = { "x-amzn-mqtt-ca", NULL }; @@ -244,6 +245,7 @@ IoT_Error_t iot_tls_connect(Network *pNetwork, TLSConnectParams *params) { return SSL_CONNECTION_ERROR; } } +#endif if((ret = mbedtls_ssl_setup(&(tlsDataParams->ssl), &(tlsDataParams->conf))) != 0) { ESP_LOGE(TAG, "failed! mbedtls_ssl_setup returned -0x%x", -ret); diff --git a/components/esp-tls/esp_tls.c b/components/esp-tls/esp_tls.c index d8411c6190..39b19f45d2 100644 --- a/components/esp-tls/esp_tls.c +++ b/components/esp-tls/esp_tls.c @@ -252,9 +252,11 @@ static int create_ssl_handle(esp_tls_t *tls, const char *hostname, size_t hostle goto exit; } +#ifdef CONFIG_MBEDTLS_SSL_ALPN if (cfg->alpn_protos) { mbedtls_ssl_conf_alpn_protocols(&tls->conf, cfg->alpn_protos); } +#endif if (cfg->use_global_ca_store == true) { if (global_cacert == NULL) {