Skip to content

mqtt: Setting null TLS hostname in mqtt_sec_config doesn't work #96853

@kevinior

Description

@kevinior

Describe the bug

In the documentation for mqtt_sec_config it says hostname "May be NULL to skip hostname verification".

The code that turns that configuration into a TLS_HOSTNAME socket option just skips setting the option if hostname is NULL. This leaves TLS_HOSTNAME set to its default value, an empty string, and causes certificate validation to fail.

It looks like TLS_HOSTNAME defaulting to an empty string was a decision made when TLS socket options were implemented.

Regression

  • This is a regression.

Steps to reproduce

  1. Build the net/secure_mqtt_sensor_actuator sample without CONFIG_MBEDTLS_SERVER_NAME_INDICATION
  2. Observer that certificate validation fails because the certificate name does not match the hostname

Relevant log output

Impact

Functional Limitation – Some features not working as expected, but system usable.

Environment

  • OS: Linux
  • SDK: zephyr-sdk-0.16.5
  • Zephyr version: both 3.7.1 and current main

Additional Context

No response

Metadata

Metadata

Assignees

Labels

area: NetworkingbugThe issue is a bug, or the PR is fixing a bug

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions