Skip to content

Commit 6ff4d53

Browse files
author
Developer
committed
Fix issue #182: Prevent -version flag from overriding finishWithCloseNotify in DTLS
When using the -version parameter with DTLS protocols, the ProtocolVersionDelegate was unconditionally setting finishWithCloseNotify to true, overriding any value that may have been set via XML configuration files. This fix removes the automatic override, allowing users to control the finishWithCloseNotify setting through their XML configuration files while still using the -version parameter for DTLS protocols. Changes: - Removed config.setFinishWithCloseNotify(true) from DTLS configuration in ProtocolVersionDelegate - Added tests to verify finishWithCloseNotify values are preserved for DTLS versions - Tests confirm both default (false) and explicitly set values are maintained
1 parent b481012 commit 6ff4d53

File tree

2 files changed

+67
-1
lines changed

2 files changed

+67
-1
lines changed

TLS-Core/src/main/java/de/rub/nds/tlsattacker/core/config/delegate/ProtocolVersionDelegate.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ public void applyDelegate(Config config) {
4949
th = TransportHandlerType.UDP;
5050
config.setDefaultLayerConfiguration(StackConfiguration.DTLS);
5151
config.setWorkflowExecutorType(WorkflowExecutorType.DTLS);
52-
config.setFinishWithCloseNotify(true);
52+
// Do not override finishWithCloseNotify - respect the configuration value
53+
// whether it comes from XML or defaults
5354
config.setIgnoreRetransmittedCssInDtls(true);
5455
}
5556

TLS-Core/src/test/java/de/rub/nds/tlsattacker/core/config/delegate/ProtocolVersionDelegateTest.java

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,69 @@ public void testNothingSetNothingChanges() {
9191
delegate.applyDelegate(config);
9292
assertTrue(EqualsBuilder.reflectionEquals(config, config2, "certificateChainConfig"));
9393
}
94+
95+
@Test
96+
public void testDTLSVersionDoesNotOverrideFinishWithCloseNotify() {
97+
// Test that setting DTLS version does not override finishWithCloseNotify setting
98+
Config config = new Config();
99+
100+
// Test with default false value
101+
assertFalse(config.isFinishWithCloseNotify());
102+
103+
String[] args = new String[2];
104+
args[0] = "-version";
105+
args[1] = "DTLS12";
106+
jcommander.parse(args);
107+
delegate.applyDelegate(config);
108+
109+
// Should remain false after applying DTLS version
110+
assertFalse(config.isFinishWithCloseNotify());
111+
assertSame(ProtocolVersion.DTLS12, config.getHighestProtocolVersion());
112+
assertSame(
113+
TransportHandlerType.UDP,
114+
config.getDefaultClientConnection().getTransportHandlerType());
115+
assertSame(
116+
TransportHandlerType.UDP,
117+
config.getDefaultServerConnection().getTransportHandlerType());
118+
}
119+
120+
@Test
121+
public void testDTLSVersionPreservesExplicitFinishWithCloseNotify() {
122+
// Test that explicitly set finishWithCloseNotify is preserved
123+
Config config = new Config();
124+
125+
// Explicitly set to true
126+
config.setFinishWithCloseNotify(true);
127+
assertTrue(config.isFinishWithCloseNotify());
128+
129+
String[] args = new String[2];
130+
args[0] = "-version";
131+
args[1] = "DTLS12";
132+
jcommander.parse(args);
133+
delegate.applyDelegate(config);
134+
135+
// Should remain true
136+
assertTrue(config.isFinishWithCloseNotify());
137+
assertSame(ProtocolVersion.DTLS12, config.getHighestProtocolVersion());
138+
}
139+
140+
@Test
141+
public void testDTLS10VersionBehavior() {
142+
// Test DTLS 1.0 as well
143+
Config config = new Config();
144+
config.setFinishWithCloseNotify(false);
145+
146+
String[] args = new String[2];
147+
args[0] = "-version";
148+
args[1] = "DTLS10";
149+
jcommander.parse(args);
150+
delegate.applyDelegate(config);
151+
152+
// Should remain false
153+
assertFalse(config.isFinishWithCloseNotify());
154+
assertSame(ProtocolVersion.DTLS10, config.getHighestProtocolVersion());
155+
assertSame(
156+
TransportHandlerType.UDP,
157+
config.getDefaultClientConnection().getTransportHandlerType());
158+
}
94159
}

0 commit comments

Comments
 (0)