Node: Is it safe to write to a TLS socket before secureConnect event?

Created on 14 Jun 2020  Â·  3Comments  Â·  Source: nodejs/node

Is it safe to write to a TLS socket before 'secureConnect' event? It's not entirely clear from the docs unless I've missed something.

question tls

Most helpful comment

As in, writing data to the socket synchronously in the same tick as tls.connect() seems to work.

It does work... but is it safe? I'm not familiar enough with TLS but is it in theory possible to send data on the wire before the connection is fully authenticated?

Might be worth to clarify in the docs.

All 3 comments

@ronag If it isn’t, then I’m pretty sure it should be… at the very least, it seems like it works in practice? As in, writing data to the socket synchronously in the same tick as tls.connect() seems to work.

As in, writing data to the socket synchronously in the same tick as tls.connect() seems to work.

It does work... but is it safe? I'm not familiar enough with TLS but is it in theory possible to send data on the wire before the connection is fully authenticated?

Might be worth to clarify in the docs.

I think this is probably fine, write goes through SSL_write which I assume would error if the write would be insecure.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mcollina picture mcollina  Â·  3Comments

loretoparisi picture loretoparisi  Â·  3Comments

vsemozhetbyt picture vsemozhetbyt  Â·  3Comments

seishun picture seishun  Â·  3Comments

fanjunzhi picture fanjunzhi  Â·  3Comments