@@ -66,14 +66,15 @@ and tap `R<CR>` (that's the letter `R` followed by a carriage return) a few
6666times.
6767
6868
69- ## NPN and SNI
69+ ## ALPN, NPN and SNI
7070
7171<!-- type=misc -->
7272
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
7475handshake extensions allowing you:
7576
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 )
7778 * SNI - to use one TLS server for multiple hostnames with different SSL
7879 certificates.
7980
@@ -249,6 +250,12 @@ automatically set as a listener for the [secureConnection][] event. The
249250 - ` NPNProtocols ` : An array or ` Buffer ` of possible NPN protocols. (Protocols
250251 should be ordered by their priority).
251252
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+
252259 - ` SNICallback(servername, cb) ` : A function that will be called if client
253260 supports SNI TLS extension. Two argument will be passed to it: ` servername ` ,
254261 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
372379 fails; ` err.code ` contains the OpenSSL error code. Default: ` true ` .
373380
374381 - ` 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'] ` .)
378392
379393 - ` servername ` : Servername for SNI (Server Name Indication) TLS extension.
380394
@@ -476,6 +490,8 @@ Construct a new TLSSocket object from existing TCP socket.
476490
477491 - ` NPNProtocols ` : Optional, see [ tls.createServer] [ ]
478492
493+ - ` ALPNProtocols ` : Optional, see [ tls.createServer] [ ]
494+
479495 - ` SNICallback ` : Optional, see [ tls.createServer] [ ]
480496
481497 - ` session ` : Optional, a ` Buffer ` instance, containing TLS session
@@ -571,7 +587,13 @@ server. If `socket.authorized` is false, then
571587` socket.authorizationError ` is set to describe how authorization
572588failed. Implied but worth mentioning: depending on the settings of the TLS
573589server, 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+
575597` socket.servername ` is a string containing servername requested with
576598SNI.
577599
@@ -744,8 +766,9 @@ The listener will be called no matter if the server's certificate was
744766authorized or not. It is up to the user to test ` tlsSocket.authorized `
745767to see if the server certificate was signed by one of the specified CAs.
746768If ` 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.
749772
750773### Event: 'OCSPResponse'
751774
0 commit comments