class TLSSocket
package js.node.tls
extends Socket › Duplex › Readable › Stream › EventEmitter
This is a wrapped version of net.Socket
that does transparent encryption
of written data and all required TLS negotiation.
Its encrypted
field is always true.
Constructor
new(socket:Socket, options:TLSSocketOptions)
Construct a new TLSSocket object from existing TCP socket.
Variables
read onlyauthorizationError:Null<String>
The reason why the peer's certificate has not been verified.
This property becomes available only when authorized
is false.
read onlyauthorized:Bool
true if the peer certificate was signed by one of the specified CAs, otherwise false
Methods
getCipher():{version:String, name:String}
Returns an object representing the cipher name and the SSL/TLS protocol version of the current connection.
Example: { name: 'AES256-SHA', version: 'TLSv1/SSLv3' }
See SSL_CIPHER_get_name() and SSL_CIPHER_get_version() in http://www.openssl.org/docs/ssl/ssl.html#DEALING_WITH_CIPHERS for more information.
getPeerCertificate(?detailed:Bool):Dynamic
Returns an object representing the peer's certificate.
The returned object has some properties corresponding to the field of the certificate.
If detailed
argument is true - the full chain with issuer property will be returned,
if false - only the top certificate without issuer property.
getProtocol():String
Returns a string containing the negotiated SSL/TLS protocol version of the current connection.
'unknown' will be returned for connected sockets that have not completed the handshaking process.
null
will be returned for server sockets or disconnected client sockets.
getSession():Null<Buffer>
Return ASN.1 encoded TLS session or null if none was negotiated. Could be used to speed up handshake establishment when reconnecting to the server.
getTLSTicket():Null<Buffer>
NOTE: Works only with client TLS sockets.
Useful only for debugging, for session reuse provide session option to tls.connect.
Return TLS session ticket or null if none was negotiated.
renegotiate(options:{requestCert:Null<Bool>, rejectUnauthorized:Null<Bool>}, ?callback:Error ‑> Void):Bool
Initiate TLS renegotiation process.
The options
may contain the following fields: rejectUnauthorized, requestCert (See Tls.createServer
for details).
callback(err)
will be executed with null as err, once the renegotiation is successfully completed.
NOTE: Can be used to request peer's certificate after the secure connection has been established. ANOTHER NOTE: When running as the server, socket will be destroyed with an error after handshakeTimeout timeout.
setMaxSendFragment(size:Int):Bool
Set maximum TLS fragment size (default and maximum value is: 16384, minimum is: 512).
Returns true on success, false otherwise.
Smaller fragment size decreases buffering latency on the client: large fragments are buffered by the TLS layer until the entire fragment is received and its integrity is verified; large fragments can span multiple roundtrips, and their processing can be delayed due to packet loss or reordering. However, smaller fragments add extra TLS framing bytes and CPU overhead, which may decrease overall server throughput.