JDK-8145849 : ALPN: getHandshakeApplicationProtocol() always return null
  • Type: Bug
  • Component: security-libs
  • Sub-Component: javax.net.ssl
  • Affected Version: 9
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2015-12-19
  • Updated: 2020-02-21
  • Resolved: 2016-01-14
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 JDK 9 Other
8u251Fixed 9 b102Fixed openjdk8u252Fixed
Related Reports
Relates :  
Description
Attached file HandShakeALPN.java is for checking ALPN value during TLS handshake, the test creates X509KeyManager for the Server and X509TrustManager for the Client respectively. When they are called to provide and check key material, check that the ALPN values are correct.
The attached test fails because the method getHandshakeApplictionProtocol() in SSLSocket class always returns null. 

java.base/share/classes/sun/security/ssl/SSLSocketImpl.java
Line 2588 -2593:
    public synchronized String getHandshakeApplicationProtocol() {
        if ((handshaker != null) && !handshaker.started()) {
            return handshaker.getHandshakeApplicationProtocol();
        }
        return null;
    }

if TLS Handshake is on-going, "!handshaker.started()" returns false , if TLS Handshake is completed, "handshaker != null" returns false.  so this method will always return null, whenever TLS Handshake is on-going or done. 
Comments
JDK-8076356 (SQE Test Dev task) is expecting that HandShakeALPN.java will be integrated as part of this fix, and thus has not integrated it yet. Please make sure this is part of the eventual fix test case.
07-01-2016

Applies to SSLEngineImpl too.
19-12-2015