Skip to content

undefined is passed as hostname to tls.checkServerIdentity #1489

Closed
@sitegui

Description

@sitegui

Hi all,

When using tls.connect(options) with no options.host I get this:

Hostname/IP doesn't match certificate's altnames: "Host: undefined. is not cert's CN: localhost"

I tried to track this and it seems tls.checkServerIdentity get called with hostname as undefined.

Examining the stack, it gets called by _tls_wrap.js:913 and hostname is defined in _tls_wrap.js:859.

As you can see, hostname is undefined because neither options.servername, options.host nor options.socket are set.

The tls.connect doc says: "If host is omitted, it defaults to localhost", so shouldn't it actually set options.host to "localhost" in this case?

Adding it to defaults may solve this, but I have very little understanding of this part of the code to be sure.

Is it a bug or intended?

Best regards

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues with confirmed bugs.tlsIssues and PRs related to the tls subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions