Skip to content

SecureSocket does not validate the name against the CN/SAN of the certificate #1421

Closed
@cmidgley

Description

@cmidgley

Build environment: Windows
Moddable SDK version: 5.0.1
Target device: ESP32, Simulator (Win)

Description
A SecureSocket connection can be made to a server even when the connection name does not match the certificate names (CN/SAN).
The connection succeeds and communicates without errors over the secure connection.

Steps to Reproduce

  1. Start with examples/network/socket/socketsecure
  2. Change the connection line to use the IP address of example.com (93.184.215.14 as of this write-up), which does not match the certificate. Alternatively, you can set up a DNS entry that resolves to that address and then use the DNS name instead of the IP address.

Line before changing:

(new SecureSocket({host, port,

Line after changing:

(new SecureSocket({host: "93.184.215.14", port,

This approach keeps the host variable referencing www.example.com so the HTTP GET will use the expected hostname (example.com requires this to return the normal page content, though it can be overridden and the connection will succeed but the HTTP payload will be an error message).

  1. Run on simulator or ESP32 and see that the connection succeeds and the page content is returned.

Other information
If the certificate is expired (or time is not set on ESP32; can't easily simulate on win as Time.set(...) isn't supported), or the certificate root is invalid, it correctly rejects the session.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions