Skip to content

Add support for wildcard hostname checks#10646

Open
rado17 wants to merge 1 commit intoMbed-TLS:developmentfrom
rado17:suffix_match
Open

Add support for wildcard hostname checks#10646
rado17 wants to merge 1 commit intoMbed-TLS:developmentfrom
rado17:suffix_match

Conversation

@rado17
Copy link
Copy Markdown

@rado17 rado17 commented Mar 18, 2026

Support configuration of wildcard hostname against which common name of certificates can be verified.

Description

Validate wildcard hostname against certificate CN. Perform domain suffix matching for certificates. This allows a configured CN (eg., "[any].example.com") to match any subdomain like "sub.example.com", "api.example.com", etc. The function extracts the domain portion from the provided hostname (everything after the first dot) and compares it case-insensitively against the CN suffix present in the certificate.

PR checklist

Please remove the segment/s on either side of the | symbol as appropriate, and add any relevant link/s to the end of the line.
If the provided content is part of the present PR remove the # symbol.

  • changelog not required because: not a user facing change
  • development PR provided here
  • TF-PSA-Crypto PR not required because: No changes
  • framework PR not required
  • 3.6 PR not required because: not breaking any APIs
  • tests no.

Support configuration of wildcard hostname against which
common name of certificates can be verified.

Signed-off-by: Ravi Dondaputi <ravi.dondaputi@nordicsemi.no>
Comment thread library/x509_crt.c
size_t i;
size_t cn_idx = 0, cn_len = strlen(cn);

/* Wildcard common name */
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This patch is incomplete — it lacks documentation and tests.

Maybe the documentation would clear it up, but I don't understand what this is supposed to do. The practical effect is that mbedtls_x509_crt_verify() and friends would accept a cn of the form *.SOMEDOMAIN, and it would mean “accept a certificate as valid if it's for any host within SOMEDOMAIN”. It would also have a similar effect on mbedtls_ssl_set_hostname().

Why? What's the use case for accepting any host within a domain with the same certificate? (Usually the reason to have multiple hosts within a domain is to have separation between subentities of an organization!) What standard would this follow?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants