Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fixup! tls: set tlsSocket.servername as early as possible
  • Loading branch information
oyyd committed May 19, 2019
commit 44f2e3d75a42a305d3b93f2afccd1ad928630a51
6 changes: 4 additions & 2 deletions lib/_tls_wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -774,8 +774,10 @@ TLSSocket.prototype._finishInit = function() {
return;

this.alpnProtocol = this._handle.getALPNNegotiatedProtocol();
// The servername could be set by TLSWrap.
this.servername = this._handle.getServername();
// The servername could be set by TLSWrap::SelectSNIContextCallback().
if (this.servername === null) {
this.servername = this._handle.getServername();
}

debug('%s _finishInit',
this._tlsOptions.isServer ? 'server' : 'client',
Expand Down
7 changes: 5 additions & 2 deletions src/tls_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1035,8 +1035,11 @@ int TLSWrap::SelectSNIContextCallback(SSL* s, int* ad, void* arg) {

// Set the servername as early as possible
Local<Object> owner = p->GetOwner();
USE(owner->Set(env->context(), env->servername_string(),
OneByteString(env->isolate(), servername)));
if (!owner->Set(env->context(),
env->servername_string(),
OneByteString(env->isolate(), servername)).FromMaybe(false)) {
return SSL_TLSEXT_ERR_NOACK;
}

if (!object->Get(env->context(), env->sni_context_string()).ToLocal(&ctx))
return SSL_TLSEXT_ERR_NOACK;
Expand Down