Skip to content
This repository has been archived by the owner on Aug 27, 2022. It is now read-only.
/ lanai Public archive

Commit

Permalink
8234408: Improve TLS session handling
Browse files Browse the repository at this point in the history
Reviewed-by: ascarpino, jjiang, ahgross, ssahoo, mullan
  • Loading branch information
XueleiFan committed Nov 25, 2019
1 parent 3dd1fd2 commit 72c7b49
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ public byte[] produce(ConnectionContext context) throws IOException {
ProtocolVersion maxProtocolVersion = chc.maximumActiveProtocol;

// session ID of the ClientHello message
SessionId sessionId = SSLSessionImpl.nullSession.getSessionId();
SessionId sessionId = new SessionId(new byte[0]);

// a list of cipher suites sent by the client
List<CipherSuite> cipherSuites = chc.activeCipherSuites;
Expand Down
16 changes: 1 addition & 15 deletions src/java.base/share/classes/sun/security/ssl/SSLSessionImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,6 @@
*/
final class SSLSessionImpl extends ExtendedSSLSession {

/*
* we only really need a single null session
*/
static final SSLSessionImpl nullSession = new SSLSessionImpl();

/*
* The state of a single session, as described in section 7.1
* of the SSLv3 spec.
Expand Down Expand Up @@ -153,7 +148,7 @@ final class SSLSessionImpl extends ExtendedSSLSession {
* be used either by a client or by a server, as a connection is
* first opened and before handshaking begins.
*/
private SSLSessionImpl() {
SSLSessionImpl() {
this.protocolVersion = ProtocolVersion.NONE;
this.cipherSuite = CipherSuite.C_NULL;
this.sessionId = new SessionId(false, null);
Expand Down Expand Up @@ -1222,15 +1217,6 @@ void setContext(SSLSessionContextImpl ctx) {
public void invalidate() {
sessionLock.lock();
try {
//
// Can't invalidate the NULL session -- this would be
// attempted when we get a handshaking error on a brand
// new connection, with no "real" session yet.
//
if (this == nullSession) {
return;
}

if (context != null) {
context.remove(sessionId);
context = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ public SSLSession getSession() {
SSLLogger.severe("handshake failed", ioe);
}

return SSLSessionImpl.nullSession;
return new SSLSessionImpl();
}

return conContext.conSession;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ private TransportContext(SSLContextImpl sslContext, SSLTransport transport,
this.isUnsureMode = isUnsureMode;

// initial security parameters
this.conSession = SSLSessionImpl.nullSession;
this.conSession = new SSLSessionImpl();
this.protocolVersion = this.sslConfig.maximumProtocolVersion;
this.clientVerifyData = emptyByteArray;
this.serverVerifyData = emptyByteArray;
Expand Down

0 comments on commit 72c7b49

Please sign in to comment.