Skip to content

Reusing TLS sessions causes to socket.servername being false #28985

Closed
@szmarczak

Description

@szmarczak
  • Version: v12.6.0
  • Platform: Linux solus 5.1.14-121.current deps: update openssl to 1.0.1j #1 SMP PREEMPT Sun Jun 23 13:57:07 UTC 2019 x86_64 GNU/Linux
  • Subsystem: tls, http2

https://runkit.com/szmarczak/5d48640bd3cab4001399357c

The issue happens randomly. Sometimes socket.servername is set to false, sometimes it's a string. I tracked the source down to this C++ code:

node/src/tls_wrap.cc

Lines 991 to 1006 in 0481a7f

void TLSWrap::GetServername(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
TLSWrap* wrap;
ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder());
CHECK_NOT_NULL(wrap->ssl_);
const char* servername = SSL_get_servername(wrap->ssl_.get(),
TLSEXT_NAMETYPE_host_name);
if (servername != nullptr) {
args.GetReturnValue().Set(OneByteString(env->isolate(), servername));
} else {
args.GetReturnValue().Set(false);
}
}

servername sometimes is a null pointer. This causes http2session.originSet to look like:

[ 'https://false:35575' ]

Metadata

Metadata

Assignees

No one assigned

    Labels

    blockedPRs that are blocked by other issues or PRs.http2Issues or PRs related to the http2 subsystem.opensslIssues and PRs related to the OpenSSL dependency.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