Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nodejs tls session id

I am using TLS to create session using node.js library. Node.js does it provide a way to retrieve session id of TLS connection established. It is part of SSL ctx in openssl.

Can it be done without using connect, express or geddy?

like image 292
Habib Avatar asked May 19 '26 14:05

Habib


2 Answers

Unfortunately I don't think that information is exposed from the SSL context for node connections.

You can access the node object representing the context as follows:

var con = tls.connect(..., ...);

con.pair.credentials.context

Unfortunately, the only methods available on that object are setKey, setCert, addCACert, addCRL, addRootCerts, setCiphers and setOptions.

That said, with a little bit of C++ and SSL know-how and come copy/pasting, you could probably patch node's node_crypto.cc and node_crypto.h files to add that lookup without TOO much work.

like image 84
loganfsmyth Avatar answered May 22 '26 09:05

loganfsmyth


You can't get the session_id but you can get the session itself for caching / resume purposes by calling conn.getSession() once the connection is established.

like image 32
Trevor Avatar answered May 22 '26 08:05

Trevor



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!