-
Notifications
You must be signed in to change notification settings - Fork 141
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
Issue with defaultServerConnection and finishWithCloseNotify Settings in DTLS #182
Comments
I am not sure I get what you are trying to do. Can you show me exactly what you did and what you expect that should happen? |
I’ve encountered a couple of issues when testing DTLS with the configuration specified in
Configuration and Command:I am running the following command to start the server: java -jar TLS-Server.jar -port 4433 -config workflow_config.xml -version DTLS12 -debug My <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<config>
<defaultPSKKey>1a2b3c4d5e6f</defaultPSKKey>
<defaultPSKIdentity>333333</defaultPSKIdentity>
<defaultPSKIdentityHint>333333</defaultPSKIdentityHint>
<defaultServerConnection>
<alias>server</alias>
<ip>127.1.11.15</ip>
<hostname>127.1.11.15</hostname>
<timeout>4000</timeout>
</defaultServerConnection>
<finishWithCloseNotify>false</finishWithCloseNotify>
<useFreshRandom>true</useFreshRandom>
</config> Expected Behavior:
Actual Behavior:
Testing with OpenSSL Client:I am testing the server with the following OpenSSL client command: openssl s_client -dtls1_2 -connect 127.0.0.1:4433 -psk 1a2b3c4d5e6f -psk_identity 333 -cipher PSK-AES256-CBC-SHA -msg -debug Could you please investigate these issues? I’m especially puzzled by the IP address behavior and the unexpected |
Ok now I get you. The ServerConnection part is related to the fact that we do not support binding to specific network interfaces but simply attach to whatever the OS hands us. We just call: Regarding the Close Notifies: This confused me as well. The reason for this is that the example evaluates the provided parameters in a specific order. Basically it first reads in your config and then changes the config according to your other provided parameters. One of them is
As you can see - it basically overwrite the FinishWithCloseNotify to true. So you can either comment out that line - or if that does not work for you you can change the config accordingly and not use the |
Thanks for the detailed explanation—it helps clarify things! Regarding the first point on binding to specific network interfaces, would it be possible to modify the code to add a binding option, such as specifying the network interface directly in DatagramSocket? If so, I’d like to explore implementing that change to target a particular interface. As for the CloseNotify behavior, I see how the -version DTLS12 flag impacts the configuration beyond just setting the protocol version. I’ll try adjusting config.setFinishWithCloseNotify(false) in my setup and avoid the -version parameter to see if that achieves the expected behavior. Let me know if you have any other suggestions or best practices for these adjustments. Thanks again! |
We have a prototype implementation for binding to specific network interfaces but it hasn't been touched in 2 years - we plan to polish it at some point and merge but I would not hold my breath |
Thank you for the update! Based on the existing prototype and its context, I’ve implemented a solution to bind the server to a specific network interface using the provided Technical Details:
Code Implementation:public class ServerUdpTransportHandler extends UdpTransportHandler {
private String srcIp;
private int port;
public ServerUdpTransportHandler(Connection con) {
super(con);
this.port = con.getPort();
this.srcIp = con.getIp();
}
public ServerUdpTransportHandler(long timeout, int port) {
super(timeout, ConnectionEndType.SERVER);
this.port = port;
}
@Override
public void initialize() throws IOException {
// Ensure the socket is initialized before proceeding
if (socket == null) {
throw new IOException("TransportHandler not pre-initialized");
}
this.initialized = true;
}
@Override
public void preInitialize() throws IOException {
// Bind the socket to the provided source IP address and port
InetAddress tempBindAddr = InetAddress.getByName(this.srcIp);
socket = new DatagramSocket(port, tempBindAddr);
cachedSocketState = null;
}
@Override
public void closeClientConnection() throws IOException {
// Properly close the client connection and socket
closeConnection();
}
} This implementation should provide the functionality to bind the server to a specific network interface (IP address) and port combination. The Please let me know if you have any further feedback or requirements, and I’d be happy to refine the solution based on your input. |
well - for your specific case it can work like this maybe - but for the project as a whole its a bit more complicated. |
Thanks for the feedback! I understand that there may be more complexity for the broader project. Just to stay aligned, is there an existing issue or improvement ticket for this functionality? If there are any plans to address it in the future, I’d be happy to contribute or support the improvements where needed. Let me know how I can assist! |
If you want to help with this: I pushed the branch with the prototype to the public repository: https://github.com/tls-attacker/TLS-Attacker/tree/specifiableInterface |
I noticed that when I provide a random value inside defaultServerConnection, it appears to be ignored and does not take effect as expected.
Additionally, I attempted to set false, but my server still sends the CloseNotify alert. Despite the configuration, the server continues to send the alert.
For context, I am currently testing DTLS
Could you please investigate this issue? Let me know if you need any additional information.
![image](https://private-user-images.githubusercontent.com/35801868/385785252-09795c6f-4c4f-4c64-b10a-0d9c04d1b6b5.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzMTc2NjUsIm5iZiI6MTczOTMxNzM2NSwicGF0aCI6Ii8zNTgwMTg2OC8zODU3ODUyNTItMDk3OTVjNmYtNGM0Zi00YzY0LWIxMGEtMGQ5YzA0ZDFiNmI1LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjExVDIzNDI0NVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWRlZWM2OThjNTQ0YWQ0M2E5OWQ5YmY2M2I4OGQzNGMzNGZjNjUxMDZiN2M1MWQwNDVkODcxODg2NDA2MDZjYTMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.HOr7Pxd2ECb-c9Ec2ayetx8Kk3Inku01Ty_etta3eL4)
The text was updated successfully, but these errors were encountered: