Description
- Version: Any
- Platform: Any
- Subsystem: tls
The recommended way to upgrade a plain socket to a TLS socket is to wrap
it with new TLSSocket(...)
.
But this wrapping doesn't check certificates
and doesn't emit secureConnect
event.
There seem to be no public API to do that checking
(at least I couldn't find it).
Method tls.connect
can be used to wrap socket to TLSSockets,
with certificate checking and with secureConnect
emision.
But it can be used only for client side sockets (isServer == false
)
and not for server side sockets got at a net.Socket connection
event.
Reading the source code, I found that checking certificates is done with
socket._handle.verifyError(), both for TLSSocket produced by tls.Server and
created with tls.connect.
This is not a documented API, and although the verifyError method has been
there for a long time, I am not sure if I should use it in user space code.
I think it would be nice to have a way to fully wrap
a plain server side socket,
with certificate checking and secureConnect
emission.
Or a public and documented API to do certificate checking.
Also, it would be nice if the documentation clearly explained
when certificates are checked and secureConnect
is emitted.