Skip to content

Commit 9b8565c

Browse files
italoacasasMyles Borins
authored and
Myles Borins
committed
doc: add added: information for tls
Ref: #6578 PR-URL: #7018 Reviewed-By: Anna Henningsen <[email protected]>
1 parent fd4aa6c commit 9b8565c

File tree

1 file changed

+112
-0
lines changed

1 file changed

+112
-0
lines changed

doc/api/tls.md

+112
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,18 @@ used properly authorized.
184184

185185

186186
## Class: tls.Server
187+
<!-- YAML
188+
added: v0.3.2
189+
-->
187190

188191
This class is a subclass of `net.Server` and has the same methods on it.
189192
Instead of accepting just raw TCP connections, this accepts encrypted
190193
connections using TLS or SSL.
191194

192195
### Event: 'clientError'
196+
<!-- YAML
197+
added: v0.11.11
198+
-->
193199

194200
`function (exception, tlsSocket) { }`
195201

@@ -199,6 +205,9 @@ established it will be forwarded here.
199205
`tlsSocket` is the [`tls.TLSSocket`][] that the error originated from.
200206

201207
### Event: 'newSession'
208+
<!-- YAML
209+
added: v0.9.2
210+
-->
202211

203212
`function (sessionId, sessionData, callback) { }`
204213

@@ -210,6 +219,9 @@ NOTE: adding this event listener will have an effect only on connections
210219
established after addition of event listener.
211220

212221
### Event: 'OCSPRequest'
222+
<!-- YAML
223+
added: v0.11.13
224+
-->
213225

214226
`function (certificate, issuer, callback) { }`
215227

@@ -248,6 +260,9 @@ NOTE: you may want to use some npm module like [asn1.js] to parse the
248260
certificates.
249261

250262
### Event: 'resumeSession'
263+
<!-- YAML
264+
added: v0.9.2
265+
-->
251266

252267
`function (sessionId, callback) { }`
253268

@@ -274,6 +289,9 @@ server.on('resumeSession', (id, cb) => {
274289
```
275290

276291
### Event: 'secureConnection'
292+
<!-- YAML
293+
added: v0.3.2
294+
-->
277295

278296
`function (tlsSocket) {}`
279297

@@ -292,34 +310,52 @@ server, you unauthorized connections may be accepted.
292310
SNI.
293311

294312
### server.addContext(hostname, context)
313+
<!-- YAML
314+
added: v0.5.3
315+
-->
295316

296317
Add secure context that will be used if client request's SNI hostname is
297318
matching passed `hostname` (wildcards can be used). `context` can contain
298319
`key`, `cert`, `ca` and/or any other properties from
299320
[`tls.createSecureContext()`][] `options` argument.
300321

301322
### server.address()
323+
<!-- YAML
324+
added: v0.6.0
325+
-->
302326

303327
Returns the bound address, the address family name and port of the
304328
server as reported by the operating system. See [`net.Server.address()`][] for
305329
more information.
306330

307331
### server.close([callback])
332+
<!-- YAML
333+
added: v0.3.2
334+
-->
308335

309336
Stops the server from accepting new connections. This function is
310337
asynchronous, the server is finally closed when the server emits a `'close'`
311338
event. Optionally, you can pass a callback to listen for the `'close'` event.
312339

313340
### server.connections
341+
<!-- YAML
342+
added: v0.3.2
343+
-->
314344

315345
The number of concurrent connections on the server.
316346

317347
### server.getTicketKeys()
348+
<!-- YAML
349+
added: v3.0.0
350+
-->
318351

319352
Returns `Buffer` instance holding the keys currently used for
320353
encryption/decryption of the [TLS Session Tickets][]
321354

322355
### server.listen(port[, hostname][, callback])
356+
<!-- YAML
357+
added: v0.3.2
358+
-->
323359

324360
Begin accepting connections on the specified `port` and `hostname`. If the
325361
`hostname` is omitted, the server will accept connections on any IPv6 address
@@ -332,11 +368,17 @@ when the server has been bound.
332368
See `net.Server` for more information.
333369

334370
### server.maxConnections
371+
<!-- YAML
372+
added: v0.2.0
373+
-->
335374

336375
Set this property to reject connections when the server's connection count
337376
gets high.
338377

339378
### server.setTicketKeys(keys)
379+
<!-- YAML
380+
added: v3.0.0
381+
-->
340382

341383
Updates the keys for encryption/decryption of the [TLS Session Tickets][].
342384

@@ -348,6 +390,9 @@ or currently pending server connections will use previous keys.
348390

349391

350392
## Class: tls.TLSSocket
393+
<!-- YAML
394+
added: v0.11.4
395+
-->
351396

352397
This is a wrapped version of [`net.Socket`][] that does transparent encryption
353398
of written data and all required TLS negotiation.
@@ -360,6 +405,9 @@ Methods that return TLS connection meta data (e.g.
360405
connection is open.
361406

362407
## new tls.TLSSocket(socket[, options])
408+
<!-- YAML
409+
added: v0.11.4
410+
-->
363411

364412
Construct a new TLSSocket object from existing TCP socket.
365413

@@ -390,6 +438,9 @@ Construct a new TLSSocket object from existing TCP socket.
390438
on the socket before establishing a secure communication
391439

392440
### Event: 'OCSPResponse'
441+
<!-- YAML
442+
added: v0.11.13
443+
-->
393444

394445
`function (response) { }`
395446

@@ -400,6 +451,9 @@ Traditionally, the `response` is a signed object from the server's CA that
400451
contains information about server's certificate revocation status.
401452

402453
### Event: 'secureConnect'
454+
<!-- YAML
455+
added: v0.11.4
456+
-->
403457

404458
This event is emitted after a new connection has been successfully handshaked.
405459
The listener will be called no matter if the server's certificate was
@@ -410,28 +464,44 @@ If `tlsSocket.authorized === false` then the error can be found in
410464
`tlsSocket.npnProtocol` for negotiated protocol.
411465

412466
### tlsSocket.address()
467+
<!-- YAML
468+
added: v0.11.4
469+
-->
413470

414471
Returns the bound address, the address family name and port of the
415472
underlying socket as reported by the operating system. Returns an
416473
object with three properties, e.g.
417474
`{ port: 12346, family: 'IPv4', address: '127.0.0.1' }`
418475

419476
### tlsSocket.authorized
477+
<!-- YAML
478+
added: v0.11.4
479+
-->
420480

421481
A boolean that is `true` if the peer certificate was signed by one of the
422482
specified CAs, otherwise `false`
423483

424484
### tlsSocket.authorizationError
485+
<!-- YAML
486+
added: v0.11.4
487+
-->
425488

426489
The reason why the peer's certificate has not been verified. This property
427490
becomes available only when `tlsSocket.authorized === false`.
428491

429492
### tlsSocket.encrypted
493+
<!-- YAML
494+
added: v0.11.4
495+
-->
430496

431497
Static boolean value, always `true`. May be used to distinguish TLS sockets
432498
from regular ones.
433499

434500
### tlsSocket.getCipher()
501+
<!-- YAML
502+
added: v0.11.4
503+
-->
504+
435505
Returns an object representing the cipher name and the SSL/TLS
436506
protocol version of the current connection.
437507

@@ -443,6 +513,9 @@ https://www.openssl.org/docs/ssl/ssl.html#DEALING-WITH-CIPHERS for more
443513
information.
444514

445515
### tlsSocket.getPeerCertificate([ detailed ])
516+
<!-- YAML
517+
added: v0.11.4
518+
-->
446519

447520
Returns an object representing the peer's certificate. The returned object has
448521
some properties corresponding to the field of the certificate. If `detailed`
@@ -479,39 +552,63 @@ If the peer does not provide a certificate, it returns `null` or an empty
479552
object.
480553

481554
### tlsSocket.getSession()
555+
<!-- YAML
556+
added: v0.11.4
557+
-->
482558

483559
Return ASN.1 encoded TLS session or `undefined` if none was negotiated. Could
484560
be used to speed up handshake establishment when reconnecting to the server.
485561

486562
### tlsSocket.getTLSTicket()
563+
<!-- YAML
564+
added: v0.11.4
565+
-->
487566

488567
NOTE: Works only with client TLS sockets. Useful only for debugging, for
489568
session reuse provide `session` option to [`tls.connect()`][].
490569

491570
Return TLS session ticket or `undefined` if none was negotiated.
492571

493572
### tlsSocket.localPort
573+
<!-- YAML
574+
added: v0.11.4
575+
-->
494576

495577
The numeric representation of the local port.
496578

497579
### tlsSocket.localAddress
580+
<!-- YAML
581+
added: v0.11.4
582+
-->
498583

499584
The string representation of the local IP address.
500585

501586
### tlsSocket.remoteAddress
587+
<!-- YAML
588+
added: v0.11.4
589+
-->
502590

503591
The string representation of the remote IP address. For example,
504592
`'74.125.127.100'` or `'2001:4860:a005::68'`.
505593

506594
### tlsSocket.remoteFamily
595+
<!-- YAML
596+
added: v0.11.4
597+
-->
507598

508599
The string representation of the remote IP family. `'IPv4'` or `'IPv6'`.
509600

510601
### tlsSocket.remotePort
602+
<!-- YAML
603+
added: v0.11.4
604+
-->
511605

512606
The numeric representation of the remote port. For example, `443`.
513607

514608
### tlsSocket.renegotiate(options, callback)
609+
<!-- YAML
610+
added: v0.11.8
611+
-->
515612

516613
Initiate TLS renegotiation process. The `options` may contain the following
517614
fields: `rejectUnauthorized`, `requestCert` (See [`tls.createServer()`][] for
@@ -525,6 +622,9 @@ ANOTHER NOTE: When running as the server, socket will be destroyed
525622
with an error after `handshakeTimeout` timeout.
526623

527624
### tlsSocket.setMaxSendFragment(size)
625+
<!-- YAML
626+
added: v0.11.11
627+
-->
528628

529629
Set maximum TLS fragment size (default and maximum value is: `16384`, minimum
530630
is: `512`). Returns `true` on success, `false` otherwise.
@@ -538,6 +638,9 @@ decrease overall server throughput.
538638

539639
## tls.connect(options[, callback])
540640
## tls.connect(port[, host][, options][, callback])
641+
<!-- YAML
642+
added: v0.11.3
643+
-->
541644

542645
Creates a new client connection to the given `port` and `host` (old API) or
543646
`options.port` and `options.host`. (If `host` is omitted, it defaults to
@@ -654,6 +757,9 @@ socket.on('end', () => {
654757
```
655758

656759
## tls.createSecureContext(details)
760+
<!-- YAML
761+
added: v0.11.13
762+
-->
657763

658764
Creates a credentials object, with the optional details being a
659765
dictionary with keys:
@@ -711,6 +817,9 @@ and the cleartext one is used as a replacement for the initial encrypted stream.
711817
NOTE: `cleartext` has the same APIs as [`tls.TLSSocket`][]
712818

713819
## tls.createServer(options[, secureConnectionListener])
820+
<!-- YAML
821+
added: v0.3.2
822+
-->
714823

715824
Creates a new [tls.Server][]. The `connectionListener` argument is
716825
automatically set as a listener for the [`'secureConnection'`][] event. The
@@ -901,6 +1010,9 @@ openssl s_client -connect 127.0.0.1:8000
9011010
```
9021011

9031012
## tls.getCiphers()
1013+
<!-- YAML
1014+
added: v0.10.2
1015+
-->
9041016

9051017
Returns an array with the names of the supported SSL ciphers.
9061018

0 commit comments

Comments
 (0)