Application-Layer Protocol Negotiation


Application-Layer Protocol Negotiation is a Transport Layer Security extension that allows the application layer to negotiate which protocol should be performed over a secure connection in a manner that avoids additional round trips and which is independent of the application-layer protocols. It is needed by secure HTTP/2 connections, which improves the compression of web pages and reduces their latency compared to HTTP/1.x. The ALPN and HTTP/2 standards emerged from development work done by Google on the now withdrawn SPDY protocol.

Support

ALPN is supported by these libraries.
On July 11, 2014, ALPN was published as RFC 7301. ALPN replaces NPN
TLS False Start was disabled in Google Chrome from version 20 onward except for websites with the earlier Next Protocol Negotiation extension.

Example

ALPN is a TLS extension which is sent on the initial TLS handshake 'Client Hello', and it lists the protocols that the client supports:

Handshake Type: Client Hello
Length: 141
Version: TLS 1.2
Random: dd67b5943e5efd0740519f38071008b59efbd68ab3114587...
Session ID Length: 0
Cipher Suites Length: 10
Cipher Suites
Compression Methods Length: 1
Compression Methods
Extensions Length: 90

Extension: application_layer_protocol_negotiation
Type: application_layer_protocol_negotiation
Length: 14
ALPN Extension Length: 12
ALPN Protocol
ALPN string length: 2
ALPN Next Protocol: h2
ALPN string length: 8
ALPN Next Protocol: http/1.1

The resulting 'Server Hello' from the web server will also contain the ALPN extension, and it confirms which protocol will be used for the HTTP request:

Handshake Type: Server Hello
Length: 94
Version: TLS 1.2
Random: 44e447964d7e8a7d3b404c4748423f02345241dcc9c7e332...
Session ID Length: 32
Session ID: 7667476d1d698d0a90caa1d9a449be814b89a0b52f470e2d...
Cipher Suite: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
Compression Method: null
Extensions Length: 22

Extension: application_layer_protocol_negotiation
Type: application_layer_protocol_negotiation
Length: 5
ALPN Extension Length: 3
ALPN Protocol
ALPN string length: 2
ALPN Next Protocol: h2