@@ -184,12 +184,18 @@ used properly authorized.
184
184
185
185
186
186
## Class: tls.Server
187
+ <!-- YAML
188
+ added: v0.3.2
189
+ -->
187
190
188
191
This class is a subclass of ` net.Server ` and has the same methods on it.
189
192
Instead of accepting just raw TCP connections, this accepts encrypted
190
193
connections using TLS or SSL.
191
194
192
195
### Event: 'clientError'
196
+ <!-- YAML
197
+ added: v0.11.11
198
+ -->
193
199
194
200
` function (exception, tlsSocket) { } `
195
201
@@ -199,6 +205,9 @@ established it will be forwarded here.
199
205
` tlsSocket ` is the [ ` tls.TLSSocket ` ] [ ] that the error originated from.
200
206
201
207
### Event: 'newSession'
208
+ <!-- YAML
209
+ added: v0.9.2
210
+ -->
202
211
203
212
` function (sessionId, sessionData, callback) { } `
204
213
@@ -210,6 +219,9 @@ NOTE: adding this event listener will have an effect only on connections
210
219
established after addition of event listener.
211
220
212
221
### Event: 'OCSPRequest'
222
+ <!-- YAML
223
+ added: v0.11.13
224
+ -->
213
225
214
226
` function (certificate, issuer, callback) { } `
215
227
@@ -248,6 +260,9 @@ NOTE: you may want to use some npm module like [asn1.js] to parse the
248
260
certificates.
249
261
250
262
### Event: 'resumeSession'
263
+ <!-- YAML
264
+ added: v0.9.2
265
+ -->
251
266
252
267
` function (sessionId, callback) { } `
253
268
@@ -274,6 +289,9 @@ server.on('resumeSession', (id, cb) => {
274
289
```
275
290
276
291
### Event: 'secureConnection'
292
+ <!-- YAML
293
+ added: v0.3.2
294
+ -->
277
295
278
296
` function (tlsSocket) {} `
279
297
@@ -292,34 +310,52 @@ server, you unauthorized connections may be accepted.
292
310
SNI.
293
311
294
312
### server.addContext(hostname, context)
313
+ <!-- YAML
314
+ added: v0.5.3
315
+ -->
295
316
296
317
Add secure context that will be used if client request's SNI hostname is
297
318
matching passed ` hostname ` (wildcards can be used). ` context ` can contain
298
319
` key ` , ` cert ` , ` ca ` and/or any other properties from
299
320
[ ` tls.createSecureContext() ` ] [ ] ` options ` argument.
300
321
301
322
### server.address()
323
+ <!-- YAML
324
+ added: v0.6.0
325
+ -->
302
326
303
327
Returns the bound address, the address family name and port of the
304
328
server as reported by the operating system. See [ ` net.Server.address() ` ] [ ] for
305
329
more information.
306
330
307
331
### server.close([ callback] )
332
+ <!-- YAML
333
+ added: v0.3.2
334
+ -->
308
335
309
336
Stops the server from accepting new connections. This function is
310
337
asynchronous, the server is finally closed when the server emits a ` 'close' `
311
338
event. Optionally, you can pass a callback to listen for the ` 'close' ` event.
312
339
313
340
### server.connections
341
+ <!-- YAML
342
+ added: v0.3.2
343
+ -->
314
344
315
345
The number of concurrent connections on the server.
316
346
317
347
### server.getTicketKeys()
348
+ <!-- YAML
349
+ added: v3.0.0
350
+ -->
318
351
319
352
Returns ` Buffer ` instance holding the keys currently used for
320
353
encryption/decryption of the [ TLS Session Tickets] [ ]
321
354
322
355
### server.listen(port[ , hostname] [ , callback ] )
356
+ <!-- YAML
357
+ added: v0.3.2
358
+ -->
323
359
324
360
Begin accepting connections on the specified ` port ` and ` hostname ` . If the
325
361
` hostname ` is omitted, the server will accept connections on any IPv6 address
@@ -332,11 +368,17 @@ when the server has been bound.
332
368
See ` net.Server ` for more information.
333
369
334
370
### server.maxConnections
371
+ <!-- YAML
372
+ added: v0.2.0
373
+ -->
335
374
336
375
Set this property to reject connections when the server's connection count
337
376
gets high.
338
377
339
378
### server.setTicketKeys(keys)
379
+ <!-- YAML
380
+ added: v3.0.0
381
+ -->
340
382
341
383
Updates the keys for encryption/decryption of the [ TLS Session Tickets] [ ] .
342
384
@@ -348,6 +390,9 @@ or currently pending server connections will use previous keys.
348
390
349
391
350
392
## Class: tls.TLSSocket
393
+ <!-- YAML
394
+ added: v0.11.4
395
+ -->
351
396
352
397
This is a wrapped version of [ ` net.Socket ` ] [ ] that does transparent encryption
353
398
of written data and all required TLS negotiation.
@@ -360,6 +405,9 @@ Methods that return TLS connection meta data (e.g.
360
405
connection is open.
361
406
362
407
## new tls.TLSSocket(socket[ , options] )
408
+ <!-- YAML
409
+ added: v0.11.4
410
+ -->
363
411
364
412
Construct a new TLSSocket object from existing TCP socket.
365
413
@@ -390,6 +438,9 @@ Construct a new TLSSocket object from existing TCP socket.
390
438
on the socket before establishing a secure communication
391
439
392
440
### Event: 'OCSPResponse'
441
+ <!-- YAML
442
+ added: v0.11.13
443
+ -->
393
444
394
445
` function (response) { } `
395
446
@@ -400,6 +451,9 @@ Traditionally, the `response` is a signed object from the server's CA that
400
451
contains information about server's certificate revocation status.
401
452
402
453
### Event: 'secureConnect'
454
+ <!-- YAML
455
+ added: v0.11.4
456
+ -->
403
457
404
458
This event is emitted after a new connection has been successfully handshaked.
405
459
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
410
464
` tlsSocket.npnProtocol ` for negotiated protocol.
411
465
412
466
### tlsSocket.address()
467
+ <!-- YAML
468
+ added: v0.11.4
469
+ -->
413
470
414
471
Returns the bound address, the address family name and port of the
415
472
underlying socket as reported by the operating system. Returns an
416
473
object with three properties, e.g.
417
474
` { port: 12346, family: 'IPv4', address: '127.0.0.1' } `
418
475
419
476
### tlsSocket.authorized
477
+ <!-- YAML
478
+ added: v0.11.4
479
+ -->
420
480
421
481
A boolean that is ` true ` if the peer certificate was signed by one of the
422
482
specified CAs, otherwise ` false `
423
483
424
484
### tlsSocket.authorizationError
485
+ <!-- YAML
486
+ added: v0.11.4
487
+ -->
425
488
426
489
The reason why the peer's certificate has not been verified. This property
427
490
becomes available only when ` tlsSocket.authorized === false ` .
428
491
429
492
### tlsSocket.encrypted
493
+ <!-- YAML
494
+ added: v0.11.4
495
+ -->
430
496
431
497
Static boolean value, always ` true ` . May be used to distinguish TLS sockets
432
498
from regular ones.
433
499
434
500
### tlsSocket.getCipher()
501
+ <!-- YAML
502
+ added: v0.11.4
503
+ -->
504
+
435
505
Returns an object representing the cipher name and the SSL/TLS
436
506
protocol version of the current connection.
437
507
@@ -443,6 +513,9 @@ https://www.openssl.org/docs/ssl/ssl.html#DEALING-WITH-CIPHERS for more
443
513
information.
444
514
445
515
### tlsSocket.getPeerCertificate([ detailed ] )
516
+ <!-- YAML
517
+ added: v0.11.4
518
+ -->
446
519
447
520
Returns an object representing the peer's certificate. The returned object has
448
521
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
479
552
object.
480
553
481
554
### tlsSocket.getSession()
555
+ <!-- YAML
556
+ added: v0.11.4
557
+ -->
482
558
483
559
Return ASN.1 encoded TLS session or ` undefined ` if none was negotiated. Could
484
560
be used to speed up handshake establishment when reconnecting to the server.
485
561
486
562
### tlsSocket.getTLSTicket()
563
+ <!-- YAML
564
+ added: v0.11.4
565
+ -->
487
566
488
567
NOTE: Works only with client TLS sockets. Useful only for debugging, for
489
568
session reuse provide ` session ` option to [ ` tls.connect() ` ] [ ] .
490
569
491
570
Return TLS session ticket or ` undefined ` if none was negotiated.
492
571
493
572
### tlsSocket.localPort
573
+ <!-- YAML
574
+ added: v0.11.4
575
+ -->
494
576
495
577
The numeric representation of the local port.
496
578
497
579
### tlsSocket.localAddress
580
+ <!-- YAML
581
+ added: v0.11.4
582
+ -->
498
583
499
584
The string representation of the local IP address.
500
585
501
586
### tlsSocket.remoteAddress
587
+ <!-- YAML
588
+ added: v0.11.4
589
+ -->
502
590
503
591
The string representation of the remote IP address. For example,
504
592
` '74.125.127.100' ` or ` '2001:4860:a005::68' ` .
505
593
506
594
### tlsSocket.remoteFamily
595
+ <!-- YAML
596
+ added: v0.11.4
597
+ -->
507
598
508
599
The string representation of the remote IP family. ` 'IPv4' ` or ` 'IPv6' ` .
509
600
510
601
### tlsSocket.remotePort
602
+ <!-- YAML
603
+ added: v0.11.4
604
+ -->
511
605
512
606
The numeric representation of the remote port. For example, ` 443 ` .
513
607
514
608
### tlsSocket.renegotiate(options, callback)
609
+ <!-- YAML
610
+ added: v0.11.8
611
+ -->
515
612
516
613
Initiate TLS renegotiation process. The ` options ` may contain the following
517
614
fields: ` rejectUnauthorized ` , ` requestCert ` (See [ ` tls.createServer() ` ] [ ] for
@@ -525,6 +622,9 @@ ANOTHER NOTE: When running as the server, socket will be destroyed
525
622
with an error after ` handshakeTimeout ` timeout.
526
623
527
624
### tlsSocket.setMaxSendFragment(size)
625
+ <!-- YAML
626
+ added: v0.11.11
627
+ -->
528
628
529
629
Set maximum TLS fragment size (default and maximum value is: ` 16384 ` , minimum
530
630
is: ` 512 ` ). Returns ` true ` on success, ` false ` otherwise.
@@ -538,6 +638,9 @@ decrease overall server throughput.
538
638
539
639
## tls.connect(options[ , callback] )
540
640
## tls.connect(port[ , host] [ , options ] [ , callback] )
641
+ <!-- YAML
642
+ added: v0.11.3
643
+ -->
541
644
542
645
Creates a new client connection to the given ` port ` and ` host ` (old API) or
543
646
` options.port ` and ` options.host ` . (If ` host ` is omitted, it defaults to
@@ -654,6 +757,9 @@ socket.on('end', () => {
654
757
```
655
758
656
759
## tls.createSecureContext(details)
760
+ <!-- YAML
761
+ added: v0.11.13
762
+ -->
657
763
658
764
Creates a credentials object, with the optional details being a
659
765
dictionary with keys:
@@ -711,6 +817,9 @@ and the cleartext one is used as a replacement for the initial encrypted stream.
711
817
NOTE: ` cleartext ` has the same APIs as [ ` tls.TLSSocket ` ] [ ]
712
818
713
819
## tls.createServer(options[ , secureConnectionListener] )
820
+ <!-- YAML
821
+ added: v0.3.2
822
+ -->
714
823
715
824
Creates a new [ tls.Server] [ ] . The ` connectionListener ` argument is
716
825
automatically set as a listener for the [ ` 'secureConnection' ` ] [ ] event. The
@@ -901,6 +1010,9 @@ openssl s_client -connect 127.0.0.1:8000
901
1010
```
902
1011
903
1012
## tls.getCiphers()
1013
+ <!-- YAML
1014
+ added: v0.10.2
1015
+ -->
904
1016
905
1017
Returns an array with the names of the supported SSL ciphers.
906
1018
0 commit comments