Skip to content

fix(esp-wolfssl): send SNI and skip OCSP when skip_common_name is set#30

Open
hrushikesh430 wants to merge 2 commits into
espressif:masterfrom
hrushikesh430:migrate/esp-idf-pr-14684
Open

fix(esp-wolfssl): send SNI and skip OCSP when skip_common_name is set#30
hrushikesh430 wants to merge 2 commits into
espressif:masterfrom
hrushikesh430:migrate/esp-idf-pr-14684

Conversation

@hrushikesh430

@hrushikesh430 hrushikesh430 commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

Background

Migrated from esp-idf PR #14684, which proposed two behaviour changes to the wolfSSL backend for esp_tls_cfg_t.skip_common_name. After review, only the SNI change is kept; the OCSP change is dropped.

✅ Kept: send SNI even when skip_common_name is set

What: when skip_common_name = true, still send the SNI extension (the server hostname) so the server returns the certificate for the requested host.

Why it's correct:

  • SNI (Server Name Indication) is about certificate selection — it tells the server which cert to present (needed for virtual hosts / CDNs). Hostname verification (CN/SAN matching) is a separate, later step. They are independent.
  • Standard TLS clients send SNI regardless of whether hostname verification is relaxed:
  • wolfSSL exposes them as separate calls too (wolfSSL_UseSNI() vs wolfSSL_check_domain_name()), so we can send SNI without doing the CN check.

⚠️ Note — differs from mbedTLS. ESP-TLS docs say skip_common_name disables SNI too (esp_tls.h L201-208); this PR keeps SNI on for wolfSSL, so the two backends differ here — an intentional, standards-aligned choice.

❌ Dropped: skipping OCSP when skip_common_name is set

The original PR also disabled OCSP status checking when skip_common_name is set, reasoning that "OCSP checks cannot succeed when the server's domain name does not match its certificate's CN." That reasoning does not hold at the protocol level, so the change is dropped:

  • An OCSP request identifies the certificate solely by issuer name hash + issuer key hash + serial number (CertID), with no reference to the server hostname/CN.
  • Therefore OCSP revocation status is independent of CN/SAN matching; an OCSP "good" response is returned regardless of whether the CN matches the connection hostname.
  • OCSP stays governed solely by CONFIG_WOLFSSL_HAVE_OCSP (off by default). Apps that don't want OCSP simply leave it disabled.

Net change

A single hunk in port/esp_tls_wolfssl.c: when skip_common_name is set, send SNI (with a NULL/length guard) instead of skipping the whole block. OCSP behaviour is unchanged from upstream.

Migrated from esp-idf PR #14684.

When esp_tls_cfg_t.skip_common_name is set, peer-certificate hostname
verification is disabled, but:
- SNI must still be sent so virtual-host / CDN servers return the
  certificate for the requested host. Previously SNI was set only inside
  the !skip_common_name branch, so it was wrongly skipped along with the
  hostname check.
- OCSP status checking is now skipped too, so the relaxed-verification
  request is not defeated by an OCSP failure.

Verified on ESP32-C5: a client with skip_common_name=true connecting to an
SNI-dependent host (www.howsmyssl.com) completes the handshake, which only
succeeds if SNI was sent so the chain verifies against the provided root CA.
@hrushikesh430 hrushikesh430 self-assigned this Jun 16, 2026
Revert the OCSP part of the skip_common_name change. OCSP revocation
checking is identified by the certificate's issuer + serial number
(RFC 6960 sec 4.1.1), not by the server hostname/CN, so it is independent
of common-name matching and does not 'fail because the CN does not match'.
OCSP remains governed solely by CONFIG_WOLFSSL_HAVE_OCSP.

The SNI change is kept: SNI (RFC 6066) selects which certificate the server
returns and is independent of hostname verification, matching common TLS
client behaviour (e.g. curl -k still sends SNI).
@hrushikesh430 hrushikesh430 marked this pull request as ready for review June 17, 2026 08:34
@hrushikesh430

Copy link
Copy Markdown
Collaborator Author

@mahavirj @AdityaHPatwardhan PTAL.

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.

1 participant