aws / amazon-freertos

DEPRECATED - See README.md
https://aws.amazon.com/freertos/
MIT License
2.54k stars 1.1k forks source link

[BUG] ALPN implementation issue #3516

Open vvelciu opened 1 year ago

vvelciu commented 1 year ago

Describe the bug _SOCKETSSetSockOpt with _SOCKETS_SO_ALPNPROTOCOLS option expects ALPN protocols to be provided as an array of char pointers. However, this is misused in the _transport_securesockets.c file in the tlsSetup() implementation: image Also, the _mqtt_demo_mutual_auth, greengrassdiscovery, ota demos configure the pAlpnProtos field as NULL (AWS_IOT_MQTT_ALPN and AWS_IOT_MQTT_ALPN_LENGTH macros are defined but left unused) and it would be nice to be properly set when the MQTT broker port is configured as 443.

System information

Expected behavior Proper usage of _SOCKETSSetSockOpt, e.g.: image

Screenshots or console output The result of using pAlpnProtos similar to _mqtt_demohelpers.c implementation: image

Steps to reproduce bug

  1. _mqtt_demo_mutualauth demo with port 443 configured as MQTT broker port
  2. Update prvConnectToServerWithBackoffRetries in _mqtt_demo_mutualauth.c file to configure pAlpnProtos (similar to _mqtt_demohelpers.c implementation): image
dachalco commented 1 year ago

Hi @vvelciu

Thanks for catching this. Certainly a bug. I'd think SocketsConfig_t needs a change so that it has a char ** ppcAlpnProtos instead -- with corresponding demo changes. I'm preparing a PR for the matter.