Skip to content

JSSE: Persist handshake session application data to final session#2137

Closed
steffen-heil-secforge wants to merge 1 commit intobcgit:mainfrom
steffen-heil-secforge:feature/handshake-session-data-persistence
Closed

JSSE: Persist handshake session application data to final session#2137
steffen-heil-secforge wants to merge 1 commit intobcgit:mainfrom
steffen-heil-secforge:feature/handshake-session-data-persistence

Conversation

@steffen-heil-secforge
Copy link

Summary

This PR makes BC JSSE consistent with Oracle JSSE by copying application data stored via putValue() in the handshake session to the final session after handshake completion.

Problem

Previously, data stored during certificate verification (e.g., in custom TrustManager implementations) would be lost when transitioning from handshake session to final session. This created inconsistent behavior compared to Oracle JSSE and broke common use cases.

Test Results

Before fix:

  • BCJSSE: value available: false (data lost)
  • SunJSSE: value available: true (data persists)

After fix:

  • BCJSSE: value available: true (data now persists)
  • SunJSSE: value available: true (unchanged)

Changes Made

  • ProvSSLEngine.java: Copy application data in notifyHandshakeComplete()
  • ProvSSLSocketDirect.java: Copy application data in notifyHandshakeComplete()
  • ProvSSLSocketWrap.java: Copy application data in notifyHandshakeComplete()
  • SessionDataPersistenceTest.java: Added test case to verify data persistence

Code Changes

Added these 4 lines to each notifyHandshakeComplete() method:

// Copy application data from handshake session to final session
String[] valueNames = handshakeSession.getValueNames();
for (String name : valueNames)
{
    connection.getSession().putValue(name, handshakeSession.getValue(name));
}

Compatibility

  • Backward Compatible: No breaking changes
  • Minimal Impact: Only affects session transition logic
  • Test Coverage: Includes regression test
  • Oracle JSSE Compatible: Aligns behavior with standard implementation

Use Cases Enabled

  • Certificate validation metadata storage
  • Security context preservation across handshake
  • Custom authentication data persistence
  • Protocol negotiation state retention

Fixes #2136

This change makes BC JSSE consistent with Oracle JSSE by copying
application data stored via putValue() in the handshake session
to the final session after handshake completion.

Previously, data stored during certificate verification (e.g., in
custom TrustManager implementations) would be lost when transitioning
from handshake session to final session.

Changes:
- Copy application data in notifyHandshakeComplete() methods
- Add test case to verify data persistence
- Maintain backward compatibility

Fixes: bcgit#2136

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@peterdettman
Copy link
Collaborator

As discussed in #2136, this PR has been superceded by changes that allow the session bindings to be shared across the session lifecycle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JSSE Provider: Handshake session data does not persist to final session (inconsistent with Oracle JSSE)

2 participants