@@ -66,14 +66,15 @@ and tap `R<CR>` (that's the letter `R` followed by a carriage return) a few
66
66
times.
67
67
68
68
69
- ## NPN and SNI
69
+ ## ALPN, NPN and SNI
70
70
71
71
<!-- type=misc -->
72
72
73
- NPN (Next Protocol Negotiation) and SNI (Server Name Indication) are TLS
73
+ ALPN (Application-Layer Protocol Negotiation Extension), NPN (Next
74
+ Protocol Negotiation) and SNI (Server Name Indication) are TLS
74
75
handshake extensions allowing you:
75
76
76
- * NPN - to use one TLS server for multiple protocols (HTTP, SPDY)
77
+ * ALPN/ NPN - to use one TLS server for multiple protocols (HTTP, SPDY, HTTP/2 )
77
78
* SNI - to use one TLS server for multiple hostnames with different SSL
78
79
certificates.
79
80
@@ -249,6 +250,12 @@ automatically set as a listener for the [secureConnection][] event. The
249
250
- ` NPNProtocols ` : An array or ` Buffer ` of possible NPN protocols. (Protocols
250
251
should be ordered by their priority).
251
252
253
+ - ` ALPNProtocols ` : An array or ` Buffer ` of possible ALPN
254
+ protocols. (Protocols should be ordered by their priority). When
255
+ the server receives both NPN and ALPN extensions from the client,
256
+ ALPN takes precedence over NPN and the server does not send an NPN
257
+ extension to the client.
258
+
252
259
- ` SNICallback(servername, cb) ` : A function that will be called if client
253
260
supports SNI TLS extension. Two argument will be passed to it: ` servername ` ,
254
261
and ` cb ` . ` SNICallback ` should invoke ` cb(null, ctx) ` , where ` ctx ` is a
@@ -372,9 +379,16 @@ Creates a new client connection to the given `port` and `host` (old API) or
372
379
fails; ` err.code ` contains the OpenSSL error code. Default: ` true ` .
373
380
374
381
- ` NPNProtocols ` : An array of strings or ` Buffer ` s containing supported NPN
375
- protocols. ` Buffer ` s should have following format: ` 0x05hello0x05world ` ,
376
- where first byte is next protocol name's length. (Passing array should
377
- usually be much simpler: ` ['hello', 'world'] ` .)
382
+ protocols. ` Buffer ` s should have the following format:
383
+ ` 0x05hello0x05world ` , where first byte is next protocol name's
384
+ length. (Passing array should usually be much simpler:
385
+ ` ['hello', 'world'] ` .)
386
+
387
+ - ` ALPNProtocols ` : An array of strings or ` Buffer ` s containing
388
+ supported ALPN protocols. ` Buffer ` s should have following format:
389
+ ` 0x05hello0x05world ` , where the first byte is the next protocol
390
+ name's length. (Passing array should usually be much simpler:
391
+ ` ['hello', 'world'] ` .)
378
392
379
393
- ` servername ` : Servername for SNI (Server Name Indication) TLS extension.
380
394
@@ -476,6 +490,8 @@ Construct a new TLSSocket object from existing TCP socket.
476
490
477
491
- ` NPNProtocols ` : Optional, see [ tls.createServer] [ ]
478
492
493
+ - ` ALPNProtocols ` : Optional, see [ tls.createServer] [ ]
494
+
479
495
- ` SNICallback ` : Optional, see [ tls.createServer] [ ]
480
496
481
497
- ` session ` : Optional, a ` Buffer ` instance, containing TLS session
@@ -571,7 +587,13 @@ server. If `socket.authorized` is false, then
571
587
` socket.authorizationError ` is set to describe how authorization
572
588
failed. Implied but worth mentioning: depending on the settings of the TLS
573
589
server, you unauthorized connections may be accepted.
574
- ` socket.npnProtocol ` is a string containing selected NPN protocol.
590
+
591
+ ` socket.npnProtocol ` is a string containing the selected NPN protocol
592
+ and ` socket.alpnProtocol ` is a string containing the selected ALPN
593
+ protocol, When both NPN and ALPN extensions are received, ALPN takes
594
+ precedence over NPN and the next protocol is selected by ALPN. When
595
+ ALPN has no selected protocol, this returns false.
596
+
575
597
` socket.servername ` is a string containing servername requested with
576
598
SNI.
577
599
@@ -744,8 +766,9 @@ The listener will be called no matter if the server's certificate was
744
766
authorized or not. It is up to the user to test ` tlsSocket.authorized `
745
767
to see if the server certificate was signed by one of the specified CAs.
746
768
If ` tlsSocket.authorized === false ` then the error can be found in
747
- ` tlsSocket.authorizationError ` . Also if NPN was used - you can check
748
- ` tlsSocket.npnProtocol ` for negotiated protocol.
769
+ ` tlsSocket.authorizationError ` . Also if ALPN or NPN was used - you can
770
+ check ` tlsSocket.alpnProtocol ` or ` tlsSocket.npnProtocol ` for the
771
+ negotiated protocol.
749
772
750
773
### Event: 'OCSPResponse'
751
774
0 commit comments