Skip to content

[AI] Fix issue #182: Prevent -version flag from overriding finishWithCloseNotify in DTLS #225

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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ public void applyDelegate(Config config) {
th = TransportHandlerType.UDP;
config.setDefaultLayerConfiguration(StackConfiguration.DTLS);
config.setWorkflowExecutorType(WorkflowExecutorType.DTLS);
config.setFinishWithCloseNotify(true);
// Do not override finishWithCloseNotify - respect the configuration value
// whether it comes from XML or defaults
config.setIgnoreRetransmittedCssInDtls(true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,69 @@ public void testNothingSetNothingChanges() {
delegate.applyDelegate(config);
assertTrue(EqualsBuilder.reflectionEquals(config, config2, "certificateChainConfig"));
}

@Test
public void testDTLSVersionDoesNotOverrideFinishWithCloseNotify() {
// Test that setting DTLS version does not override finishWithCloseNotify setting
Config config = new Config();

// Test with default false value
assertFalse(config.isFinishWithCloseNotify());

String[] args = new String[2];
args[0] = "-version";
args[1] = "DTLS12";
jcommander.parse(args);
delegate.applyDelegate(config);

// Should remain false after applying DTLS version
assertFalse(config.isFinishWithCloseNotify());
assertSame(ProtocolVersion.DTLS12, config.getHighestProtocolVersion());
assertSame(
TransportHandlerType.UDP,
config.getDefaultClientConnection().getTransportHandlerType());
assertSame(
TransportHandlerType.UDP,
config.getDefaultServerConnection().getTransportHandlerType());
}

@Test
public void testDTLSVersionPreservesExplicitFinishWithCloseNotify() {
// Test that explicitly set finishWithCloseNotify is preserved
Config config = new Config();

// Explicitly set to true
config.setFinishWithCloseNotify(true);
assertTrue(config.isFinishWithCloseNotify());

String[] args = new String[2];
args[0] = "-version";
args[1] = "DTLS12";
jcommander.parse(args);
delegate.applyDelegate(config);

// Should remain true
assertTrue(config.isFinishWithCloseNotify());
assertSame(ProtocolVersion.DTLS12, config.getHighestProtocolVersion());
}

@Test
public void testDTLS10VersionBehavior() {
// Test DTLS 1.0 as well
Config config = new Config();
config.setFinishWithCloseNotify(false);

String[] args = new String[2];
args[0] = "-version";
args[1] = "DTLS10";
jcommander.parse(args);
delegate.applyDelegate(config);

// Should remain false
assertFalse(config.isFinishWithCloseNotify());
assertSame(ProtocolVersion.DTLS10, config.getHighestProtocolVersion());
assertSame(
TransportHandlerType.UDP,
config.getDefaultClientConnection().getTransportHandlerType());
}
}