Skip to content

tlsSocket.getProtocol() does not return null for server sockets #56935

Open
@toramanomer

Description

@toramanomer

Version

v22.9.0

Platform

Darwin Omers-MacBook-Pro.local 24.2.0 Darwin Kernel Version 24.2.0: Fri Dec  6 19:01:59 PST 2024; root:xnu-11215.61.5~2/RELEASE_ARM64_T6000 arm6

Subsystem

tls

What steps will reproduce the bug?

When a new instance of TLSSocket is created with the options.isServer set as true, the getProtocol instance method does not return null.

I'm not sure if this qualifies as a bug, however, the docs states as follows:

The value null will be returned for server sockets or disconnected client sockets.

import { TLSSocket } from 'node:tls'
import { Socket } from 'node:net'

const tlsSocket = new TLSSocket(new Socket(), {
	isServer: true
})

console.log('TLS Socket Protocol:', tlsSocket.getProtocol()) // TLSv1.3

Adding versions of openssl as well as default min and max versions if it might be helpful:

import { versions } from 'node:process'
import { DEFAULT_MIN_VERSION, DEFAULT_MAX_VERSION } from 'node:tls'

console.log(versions.openssl)                   // 3.0.13+quic
console.log(DEFAULT_MIN_VERSION)     // TLSv1.2
console.log(DEFAULT_MAX_VERSION)    // TLSv1.3

How often does it reproduce? Is there a required condition?

I have not seen it returning null.

What is the expected behavior? Why is that the expected behavior?

The expected behavior is that it returns null as described per docs here:
https://nodejs.org/api/tls.html#tlssocketgetprotocol

What do you see instead?

I instead see the string value TLSv1.3.

Additional information

No response

Activity

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

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