Extend the `javax.net.ssl` package to support the TLS
[Application Layer Protocol Negotiation (ALPN) Extension](http://www.rfc-editor.org/rfc/rfc7301.txt),
which provides the means to negotiate an application protocol for a TLS connection.
In order to support TLS clients and servers wishing to use multiple
application-layer protocols over the same transport-layer port, the ALPN
extension allows a client to provide a list of the application-layer
protocols it supports, in order of preference. A server can then select
one of the advertised client protocols and tell the client which protocol
will be used in the TLS connection.
One important consumer of this TLS extension will be the
[HTTP/2 client (JEP 110)](http://openjdk.java.net/jeps/110), which will
This feature defines a public API to negotiate the application-layer
protocols that can be transmitted over a given TLS connection. Protocol
names are conveyed between client and server during the initial TLS
A TLS application can use an
extended `SSLParameters` class to get and set the list of
application-layer protocols that it can support on a given connection.
The TLS implementation also uses this class to retrieve the protocol
names declared by the application.
The default behavior is to select the server's most-preferred intersection value
of the enabled application protocol values.
Server applications can also externally scan the initial plaintext ClientHellos to select an
appropriate ALPN protocol value for this connection.
This decision might be made based on offered
TLS protocols, ciphersuites, Server Name Indication values, etc. The server
application can then:
- select one of the offered protocols if it will support it,
- decide the remotely offered and locally supported ALPN values are mutually exclusive, or
- ignore the extension completely.
A server may alter connection parameters, such as the server certificate
it advertises, based on which application protocols are available during the
After the SSL/TLS handshake has started, there are new methods on `SSLSocket/SSLEngine`
that allow the application to query if an ALPN value has been selected yet (`getHandshakeApplicationProtocol()`).
Once the TLS handshake has completed, an application can then
examine which protocol has been negotiated using the
The proposed design follows a similar API methodology used for the
[Server Name Indication Extension (JEP 114)](http://openjdk.java.net/jeps/114),
introduced in JDK 8, but differs in that ALPN values are tied to the connection,
not the `SSLSession`.
- Client-side implementations should be able to work with HTTP/2 and SPDY-capable
web servers (_e.g._, Apache/mod_spdy, Jetty, and possibly others). SPDY is becoming
less important, as HTTP/2 is its very public replacement. SPDY implementations should
become scarce very soon. We will certainly test using the new HTTP/2 client from JEP 110.
- Server-side implementations should be tested against well-known TLS
client implementations capable of using ALPN (_e.g._, GnuTLS, NSS,
OpenSSL(beta), and Microsoft SChannel 8.1). We do not currently
plan on introducing any server-side ALPN-enabled applications.
Most testing here will be some simple TLS handshakes and checking
the negotiated values.