ALPN

May 20, 2023

The Application-Layer Protocol Negotiation (ALPN) is an extension to the Transport Layer Security (TLS) protocol that allows the client and the server to negotiate which application protocol to use over the secured connection. ALPN is a key component in improving the performance and security of modern web applications.

Purpose

ALPN is designed to solve a significant performance problem with TLS. When a client (such as a web browser) and a server establish a TLS connection, the server sends the list of supported protocols to the client. The client then selects the protocol it wishes to use, and the server responds accordingly. This negotiation process can add significant latency to the connection, especially when dealing with slow or unreliable networks.

ALPN solves this problem by allowing the client and server to negotiate the protocol during the initial TLS handshake. This means that the client can send its list of supported protocols to the server during the initial handshake, and the server can respond with the selected protocol. This eliminates the need for an additional round-trip, reducing latency and improving performance.

Another benefit of ALPN is that it can improve the security of web applications. By allowing the server to select the protocol, it can ensure that the connection uses the most secure protocol available. For example, if the server supports both HTTP/1.1 and HTTP/2, it can use HTTP/2, which is more secure and efficient than HTTP/1.1.

Usage

ALPN is primarily used in modern web applications that require a secure connection. This includes websites that handle sensitive data such as login credentials, personal information, and financial data.

ALPN is supported by most modern web browsers and web servers. It is part of the TLS 1.3 specification and is widely used in the industry. Most web servers support ALPN by default, and web developers can enable it in their applications by configuring their server and client software.

To use ALPN, the client and server must support the TLS 1.3 protocol. The client sends its list of supported protocols in the ClientHello message during the initial TLS handshake. The server responds with its selected protocol in the ServerHello message.

If the client and server do not support the same protocol, the connection will fail. However, this is a rare occurrence as most web servers and browsers support multiple protocols.