new tls.TLSSocket crash using SNICallback

55 views
Skip to first unread message

Webert de Souza Lima

unread,
Jan 5, 2017, 1:18:24 AM1/5/17
to nodejs
Hello,

I have an e-mail application written in nodejs that uses STARTTLS.
For those not familiar, the connection is open through a regular, non-encrypted net.socket and it gets encrypted after this command is issued.

Now i'm trying to implement SNICallback to load the proper SSL certificate, but very often the app crashes with the following stack trace:

_tls_wrap.js:117
  if (ctx.context)
         ^
TypeError: Cannot read property 'context' of undefined
    at requestOCSP (_tls_wrap.js:117:10)
    at _tls_wrap.js:167:5
    at loadSNI (_tls_wrap.js:88:12)
    at TLSSocket.oncertcb (_tls_wrap.js:164:3)
    at TLSWrap.ssl.oncertcb (_tls_wrap.js:397:39)

What I do is:

var options = {
server : netServer, 
SNICallback : SNICallback, 
}
...
var tlsSocket = new tls.TLSSocket(netSocket, {
server : netServer, //this is the net.Server instance
requestCert : false,
rejectUnauthorized : false,
SNICallback : SNICallback, //this is a function (hostname, callback)
requestOCSP : false,
});

I'm not yet able to reproduce it on a test environment, it only happens in production so I think it may be something with client disconnecting right after issuing this command.
In a test environment (telnet) it all works perfectly. In production it works for hundreds of connections until randomly crashes.

Webert de Souza Lima

unread,
Jan 5, 2017, 2:34:28 PM1/5/17
to nodejs
That was in nodejs version 6.2. This is from version 6.9.2:

 _tls_wrap.js:117
   if (ctx.context)
          ^
 
 TypeError: Cannot read property 'context' of undefined
     at requestOCSP (_tls_wrap.js:117:10)
     at _tls_wrap.js:167:5
     at loadSNI (_tls_wrap.js:88:12)
     at TLSSocket.oncertcb (_tls_wrap.js:164:3)
     at TLSWrap.ssl.oncertcb (_tls_wrap.js:418:39)
Reply all
Reply to author
Forward
0 new messages