Class TLSSocket
Hierarchy
-
Socket
- TLSSocket
Implements
Index
Constructors
Properties
Methods
- _read
- _write
- add
Listener - address
- emit
- end
- event
Names - get
Cipher - get
Max Listeners - get
Peer Certificate - get
Session - getTLSTicket
- is
Paused - listener
Count - listeners
- on
- once
- pause
- pipe
- prepend
Listener - prepend
Once Listener - push
- read
- remove
All Listeners - remove
Listener - renegotiate
- resume
- set
Default Encoding - set
Encoding - set
Max Listeners - set
Max Send Fragment - unpipe
- unshift
- wrap
- write
- add
Listener - address
- connect
- destroy
- emit
- end
- listener
Count - on
- once
- prepend
Listener - prepend
Once Listener - ref
- set
Encoding - set
Keep Alive - set
NoDelay - set
Timeout - unref
- write
Constructors
constructor
-
Parameters
-
socket: Socket
-
Optional options: object
-
Optional ALPNProtocols?: string[] | Buffer
An array of strings or a Buffer naming possible ALPN protocols. (Protocols should be ordered by their priority.) When the server receives both NPN and ALPN extensions from the client, ALPN takes precedence over NPN and the server does not send an NPN extension to the client.
-
Optional NPNProtocols?: string[] | Buffer
An array of strings or a Buffer naming possible NPN protocols. (Protocols should be ordered by their priority.)
-
Optional SNICallback?: Function
SNICallback(servername, cb)
A function that will be called if the client supports SNI TLS extension. Two arguments will be passed when called: servername and cb. SNICallback should invoke cb(null, ctx), where ctx is a SecureContext instance. (tls.createSecureContext(...) can be used to get a proper SecureContext.) If SNICallback wasn't provided the default callback with high-level API will be used (see below). -
Optional is
Server?: boolean If true the TLS socket will be instantiated in server-mode. Defaults to false.
-
Optional reject
Unauthorized?: boolean If true the server will reject any connection which is not authorized with the list of supplied CAs. This option only has an effect if requestCert is true. Defaults to false.
-
Optional request
Cert?: boolean If true the server will request a certificate from clients that connect and attempt to verify that certificate. Defaults to false.
-
Optional requestOCSP?: boolean
If true, specifies that the OCSP status request extension will be added to the client hello and an 'OCSPResponse' event will be emitted on the socket before establishing a secure communication
-
Optional secure
Context?: SecureContext An optional TLS context object from tls.createSecureContext()
-
Optional server?: Server
An optional net.Server instance.
-
Optional session?: Buffer
An optional Buffer instance containing a TLS session.
-
Returns TLSSocket
-
Properties
authorizationError
The reason why the peer's certificate has not been verified. This property becomes available only when tlsSocket.authorized === false.
authorized
A boolean that is true if the peer certificate was signed by one of the specified CAs, otherwise false.
encrypted
Static boolean value, always true. May be used to distinguish TLS sockets from regular ones.
localAddress
The string representation of the local IP address.
localPort
The numeric representation of the local port.
readable
remoteAddress
The string representation of the remote IP address. For example, '74.125.127.100' or '2001:4860:a005::68'.
remoteFamily
The string representation of the remote IP family. 'IPv4' or 'IPv6'.
remotePort
The numeric representation of the remote port. For example, 443.
writable
Static Socket
Type declaration
-
constructor: function
-
Parameters
-
Optional options: object
-
Optional allow
Half Open?: boolean -
Optional fd?: number
-
Optional readable?: boolean
-
Optional writable?: boolean
-
Returns Socket
-
-
Static bufferSize
Static bytesRead
Static bytesWritten
Static connecting
Static defaultMaxListeners
Static destroyed
Static localAddress
Static localPort
Static remoteAddress
Static remoteFamily
Static remotePort
Methods
_read
-
Parameters
-
size: number
Returns void
-
_write
-
Parameters
-
chunk: any
-
encoding: string
-
callback: Function
Returns void
-
addListener
-
events.EventEmitter
- OCSPResponse
- secureConnect
Parameters
-
event: string
-
listener: Function
Returns this
-
Parameters
-
event: "OCSPResponse"
-
listener: function
-
-
Parameters
-
response: Buffer
Returns void
-
-
-
Returns this
-
-
Parameters
-
event: "secureConnect"
-
listener: function
-
-
Returns void
-
-
Returns this
-
address
-
Returns the bound address, the address family name and port of the underlying socket as reported by the operating system.
Returns object
- An object with three properties, e.g. { port: 12346, family: 'IPv4', address: '127.0.0.1' }.
-
address: string
-
family: string
-
port: number
emit
-
Parameters
-
event: string | symbol
-
Rest ...args: any[]
Returns boolean
-
-
Parameters
-
event: "OCSPResponse"
-
response: Buffer
Returns boolean
-
-
Parameters
-
event: "secureConnect"
Returns boolean
-
end
-
Returns void
eventNames
-
Returns (string | symbol)[]
getCipher
-
Returns an object representing the cipher name and the SSL/TLS protocol version of the current connection.
Returns CipherNameAndProtocol
- Returns an object representing the cipher name and the SSL/TLS protocol version of the current connection.
getMaxListeners
-
Returns number
getPeerCertificate
-
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. If the peer does not provide a certificate, it returns null or an empty object.
Parameters
-
Optional detailed: boolean
If true; the full chain with issuer property will be returned.
Returns object
- An object representing the peer's certificate.
-
fingerprint: string
-
issuer: Certificate
-
issuer
Info: Certificate -
raw: any
-
serial
Number: string -
subject: Certificate
-
valid_
from: string -
valid_
to: string
-
getSession
-
Could be used to speed up handshake establishment when reconnecting to the server.
Returns any
- ASN.1 encoded TLS session or undefined if none was negotiated.
getTLSTicket
-
NOTE: Works only with client TLS sockets. Useful only for debugging, for session reuse provide session option to tls.connect().
Returns any
- TLS session ticket or undefined if none was negotiated.
isPaused
-
Returns boolean
listenerCount
-
Parameters
-
type: string | symbol
Returns number
-
listeners
-
Parameters
-
event: string | symbol
Returns Function[]
-
on
-
Parameters
-
event: string
-
listener: Function
Returns this
-
-
Parameters
-
event: "OCSPResponse"
-
listener: function
-
-
Parameters
-
response: Buffer
Returns void
-
-
-
Returns this
-
-
Parameters
-
event: "secureConnect"
-
listener: function
-
-
Returns void
-
-
Returns this
-
once
-
Parameters
-
event: string
-
listener: Function
Returns this
-
-
Parameters
-
event: "OCSPResponse"
-
listener: function
-
-
Parameters
-
response: Buffer
Returns void
-
-
-
Returns this
-
-
Parameters
-
event: "secureConnect"
-
listener: function
-
-
Returns void
-
-
Returns this
-
pause
-
Returns this
pipe
-
Type parameters
Parameters
-
destination: T
-
Optional options: object
-
Optional end?: boolean
-
Returns T
-
prependListener
-
Parameters
-
event: string
-
listener: Function
Returns this
-
-
Parameters
-
event: "OCSPResponse"
-
listener: function
-
-
Parameters
-
response: Buffer
Returns void
-
-
-
Returns this
-
-
Parameters
-
event: "secureConnect"
-
listener: function
-
-
Returns void
-
-
Returns this
-
prependOnceListener
-
Parameters
-
event: string
-
listener: Function
Returns this
-
-
Parameters
-
event: "OCSPResponse"
-
listener: function
-
-
Parameters
-
response: Buffer
Returns void
-
-
-
Returns this
-
-
Parameters
-
event: "secureConnect"
-
listener: function
-
-
Returns void
-
-
Returns this
-
push
-
Parameters
-
chunk: any
-
Optional encoding: string
Returns boolean
-
read
-
Parameters
-
Optional size: number
Returns any
-
removeAllListeners
-
Parameters
-
Optional event: string | symbol
Returns this
-
removeListener
-
Parameters
-
event: string
-
listener: Function
Returns this
-
-
Parameters
-
event: "close"
-
listener: function
-
-
Returns void
-
-
Returns this
-
-
Parameters
-
event: "data"
-
listener: function
-
-
Parameters
-
chunk: Buffer | string
Returns void
-
-
-
Returns this
-
-
Parameters
-
event: "end"
-
listener: function
-
-
Returns void
-
-
Returns this
-
-
Parameters
-
event: "readable"
-
listener: function
-
-
Returns void
-
-
Returns this
-
-
Parameters
-
event: "error"
-
listener: function
-
-
Parameters
-
err: Error
Returns void
-
-
-
Returns this
-
renegotiate
-
Initiate TLS renegotiation process.
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.
Parameters
-
options: TlsOptions
The options may contain the following fields: rejectUnauthorized, requestCert (See tls.createServer() for details).
-
callback: function
callback(err) will be executed with null as err, once the renegotiation is successfully completed.
-
-
Parameters
-
err: Error
Returns any
-
-
-
Returns any
-
resume
-
Returns this
setDefaultEncoding
-
Parameters
-
encoding: string
Returns this
-
setEncoding
-
Parameters
-
encoding: string
Returns void
-
setMaxListeners
-
Parameters
-
n: number
Returns this
-
setMaxSendFragment
-
Set maximum TLS fragment size (default and maximum value is: 16384, minimum is: 512). 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.
Parameters
-
size: number
TLS fragment size (default and maximum value is: 16384, minimum is: 512).
Returns boolean
- Returns true on success, false otherwise.
-
unpipe
-
Type parameters
Parameters
-
Optional destination: T
Returns void
-
unshift
-
Parameters
-
chunk: any
Returns void
-
wrap
-
Parameters
-
oldStream: ReadableStream
Returns Readable
-
write
-
Parameters
-
chunk: any
-
Optional cb: Function
Returns boolean
-
Static addListener
-
events.EventEmitter
- close
- connect
- data
- drain
- end
- error
- lookup
- timeout
Parameters
-
event: string
-
listener: Function
Returns this
Static address
-
Returns object
-
address: string
-
family: string
-
port: number
-
Static connect
-
Parameters
-
port: number
-
Optional host: string
-
Optional connectionListener: Function
Returns void
-
-
Parameters
-
path: string
-
Optional connectionListener: Function
Returns void
-
Static destroy
-
Returns void
Static emit
-
Parameters
-
event: string | symbol
-
Rest ...args: any[]
Returns boolean
-
Static end
-
Returns void
-
Parameters
-
buffer: Buffer
-
Optional cb: Function
Returns void
-
-
Parameters
-
str: string
-
Optional cb: Function
Returns void
-
-
Parameters
-
str: string
-
Optional encoding: string
-
Optional cb: Function
Returns void
-
-
Parameters
-
Optional data: any
-
Optional encoding: string
Returns void
-
Static listenerCount
-
Parameters
-
emitter: EventEmitter
-
event: string | symbol
Returns number
-
Static on
-
Parameters
-
event: string
-
listener: Function
Returns this
-
Static once
-
Parameters
-
event: string
-
listener: Function
Returns this
-
Static prependListener
-
Parameters
-
event: string
-
listener: Function
Returns this
-
Static prependOnceListener
-
Parameters
-
event: string
-
listener: Function
Returns this
-
Static ref
-
Returns void
Static setEncoding
-
Parameters
-
Optional encoding: string
Returns void
-
Static setKeepAlive
-
Parameters
-
Optional enable: boolean
-
Optional initialDelay: number
Returns void
-
Static setNoDelay
-
Parameters
-
Optional noDelay: boolean
Returns void
-
Static setTimeout
-
Parameters
-
timeout: number
-
Optional callback: Function
Returns void
-
Static unref
-
Returns void
Static write
-
Parameters
-
buffer: Buffer
Returns boolean
-
-
Parameters
-
buffer: Buffer
-
Optional cb: Function
Returns boolean
-
-
Parameters
-
str: string
-
Optional cb: Function
Returns boolean
-
-
Parameters
-
str: string
-
Optional encoding: string
-
Optional cb: Function
Returns boolean
-
-
Parameters
-
str: string
-
Optional encoding: string
-
Optional fd: string
Returns boolean
-
-
Parameters
-
data: any
-
Optional encoding: string
-
Optional callback: Function
Returns void
-
Generated using TypeDoc
Construct a new tls.TLSSocket object from an existing TCP socket.