Skip to content

[AI] Fix NPE in PreSharedKeyExtensionMessage for TLS 1.3 PSK handshake #219

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ic0ns
Copy link
Contributor

@ic0ns ic0ns commented Jun 26, 2025

Summary

  • Fixed NullPointerException in PreSharedKeyExtensionMessage.copyPskSets method
  • Added missing initialization of identities and binders lists in Config constructor
  • Added comprehensive unit tests to verify the fix

Description

The issue reported in #188 was caused by the copyPskSets method in PreSharedKeyExtensionMessage not setting the identity field in PSKIdentity objects. This caused a NullPointerException when PreSharedKeyExtensionHandler tried to access pskIdentity.getIdentity().getValue() during TLS 1.3 PSK handshakes.

The fix adds the missing line:

pskIdentity.setIdentity(pskSets.get(x).getPreSharedKeyIdentity());

Additionally, I found and fixed another issue where the identities and binders lists were not initialized in the Config constructor when no PSK sets were configured, which could lead to NPEs in other scenarios.

Test plan

  • Added unit tests for PreSharedKeyExtensionMessage covering:
    • PSK sets copied correctly with identity field set
    • Limit PSKs to one functionality
    • Empty PSK sets configuration
  • All existing tests pass
  • Code compiles successfully
  • Spotless formatting applied

Fixes #188

The PreSharedKeyExtensionMessage.copyPskSets method was not setting the identity
field in PSKIdentity objects, causing a NullPointerException when the
PreSharedKeyExtensionHandler tried to access the identity value during
TLS 1.3 PSK handshakes.

This fix ensures that the identity field is properly set when copying PSK sets,
allowing TLS 1.3 PSK handshakes to complete successfully.

Also fixed initialization of identities and binders lists in the Config
constructor to prevent NPE when no PSK sets are configured.

Added comprehensive unit tests to verify the fix works correctly.

Fixes #188
@ic0ns ic0ns changed the title Fix NPE in PreSharedKeyExtensionMessage for TLS 1.3 PSK handshake [AI] Fix NPE in PreSharedKeyExtensionMessage for TLS 1.3 PSK handshake Jun 26, 2025
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.

TLS 1.3 with PSK Cipher
1 participant