I'm reading the spec and trying to understand exactly when 421 might be returned. An example is given but I don't completely understand it.
Background
The spec establishes two conditions that allow for connection reuse:
For TCP connections without TLS, this depends on the host having resolved to the same IP address.
and
For https resources, connection reuse additionally depends on having a certificate that is valid for the host in the URI.
If the certificate used in the connection has multiple subjectAltName
or any of the subjectAltName
is a wildcard, then the connection can be reused for any request that has a hostname that is in the list of subjectAltName
s or matches any of the wildcards.
Specific Example In the spec
In some deployments, reusing a connection for multiple origins can result in requests being directed to the wrong origin server. For example, TLS termination might be performed by a middlebox that uses the TLS Server Name Indication (SNI) [TLS-EXT] extension to select an origin server. This means that it is possible for clients to send confidential information to servers that might not be the intended target for the request, even though the server is otherwise authoritative.
Please explain where my understanding of this example is wrong:
An https connection is established to a middlebox with a request that has domain x.com
. The middlebox has IP address 1.2.3.4 and x.com
resolves to that address. Using SNI, the TLS handshake has x.com
and the middlebox returns a certificate valid for that domain. All messages on this connection go from the client to the middlebox or from middlebox to client. Applicaiton level messages from client to middlebox are forwarded by middlebox to an origin on a different connection. Messages from origin to middlebox are forwarded to the client. If the connection is to be reused, meeting the two conditions discussed above is not enough. Specifically, for a request with domain y.com
: if y.com
resolves to 1.2.3.4 and the middlebox has a certificate valid for y.com
, there can still be a problem. Because the original connection did its TLS handshake using x.com
and because handshakes are only done at the beginning of new connections, there is no way establishing an https connection that would get the certificate for y.com
. So the client incorrectly sends a request on the same connection to y.com
. The middlebox rejects the request because the certificate associated with the connection is valid for x.com
- not y.com
. (The x.com
certificate is only valid for x.com
and the y.com
certificate is only valid for y.com
).