# What Is ALPN (Application-Layer Protocol Negotiation)?

> ALPN is a TLS extension that lets client and server agree on the application protocol, such as h2 or http/1.1, inside the TLS handshake.

Source: https://ssl.sh/glossary/alpn/
Last updated: 2026-11-10

Application-Layer Protocol Negotiation is defined in [RFC 7301](https://www.rfc-editor.org/rfc/rfc7301). The client lists the protocols it supports by registered identifier, for example `h2` and `http/1.1`, in its ClientHello; the server picks one and returns it. In TLS 1.3 the server's choice travels in the encrypted EncryptedExtensions message, while the client's list stays visible in the plaintext ClientHello.

## Why it matters
Browsers speak HTTP/2 over TLS only when it is negotiated through ALPN, so a server or proxy that does not offer `h2` silently gets HTTP/1.1. HTTP/3 over [QUIC](https://ssl.sh/glossary/quic/) uses the identifier `h3`. ALPN is also the basis of the ACME [TLS-ALPN-01](https://ssl.sh/glossary/tls-alpn-01/) challenge: the CA connects offering the `acme-tls/1` protocol, and the server answers with a special validation certificate instead of its normal one. Because the protocol is fixed during the handshake, RFC 7301 expects a server that supports none of the offered protocols to abort with a `no_application_protocol` alert rather than fail later at the HTTP layer.

## Example
```bash
openssl s_client -connect example.com:443 -servername example.com -alpn h2,http/1.1 </dev/null 2>/dev/null | grep -i alpn
# ALPN protocol: h2
```

In nginx, HTTP/2 (and with it the `h2` ALPN value) is enabled with `http2 on;` in newer versions or `listen 443 ssl http2;` in older ones.

## Common misconceptions
- **ALPN negotiates the TLS version.** No. TLS version and cipher suite are negotiated separately; ALPN only picks the protocol that runs on top of TLS.
- **ALPN is the same as NPN.** NPN was an earlier, Google-designed extension in which the client chose the protocol. It has been replaced by ALPN, in which the server chooses.
- **Enabling HTTP/2 in the application is enough.** If the proxy doing [TLS termination](https://ssl.sh/glossary/tls-termination/) in front of it does not advertise `h2`, clients still use HTTP/1.1.

## Related terms

- [TLS 握手](https://ssl.sh/zh/glossary/tls-handshake/): TLS 握手是 TLS 连接开始时的一组消息交换，客户端与服务器在其中协商协议版本和密码套件、验证服务器身份并派生会话密钥。
- [SNI](https://ssl.sh/zh/glossary/sni/): SNI 是 TLS 的一个扩展，客户端在 ClientHello 中写明要访问的域名，使同一个 IP 能为多个 HTTPS 站点分别返回各自的证书。
- [QUIC](https://ssl.sh/zh/glossary/quic/): QUIC 是基于 UDP、始终加密的传输协议，把 TLS 1.3 握手内置在传输层中，HTTP/3 就运行在它之上。
- [TLS-ALPN-01](https://ssl.sh/zh/glossary/tls-alpn-01/): TLS-ALPN-01 是一种 ACME 验证方式，服务器在 443 端口针对 acme-tls/1 协议出示一张特殊证书来证明域名控制权。
- [TLS 1.3](https://ssl.sh/zh/glossary/tls-1-3/): TLS 1.3 是当前最新的传输层安全协议版本（2018 年的 RFC 8446，现行规范为 RFC 9846），完整握手只需一个往返，且只保留 AEAD 加密算法。
- [TLS 终止](https://ssl.sh/zh/glossary/tls-termination/): TLS 终止是指网络路径上客户端 TLS 连接结束并被解密的位置，可以是 CDN 边缘、负载均衡、反向代理，也可以是应用服务器本身。
