-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
TLS Handshake record layer fragmentation not working #1840
Comments
@Irrialite As you can see from this PR we are working an refactoring the messaging infrastructure. Message fragmentation being one of the issues addressed. |
You are welcome to try this PR and ad your comments though. |
Note that this PR does require integration with the rest of the library though. |
@Irrialite I have just looked again at your query. |
@Irrialite I would like to clarify, that my previous comment was about the Application data. I now realize you were asking about the Handshake message length. The standard doesn't limit the length of the handshake message( except that the length field is 24 bits, so the message cannot exceed 32MB). In addition, the Fragmentation support which is being worked on, is about the DLTS fragmentation. Supporting TLS fragmentation is not at the moment planned, as usually it's not a problem. |
We believe this issue has been addressed, therefore closing. |
Reopening, for the sake of tracking the TLS handshake fragmentation feature |
@RonEld this is more serious when Max Fragment Length is used. if a device (using mbedTLS) asks for a small fragment, e.g. 1024 bytes, and the server complies, then handshake ends up fragmented:
which leads to the "fragmented handshake" failure. |
@rojer Thank you for your example. |
@RonEld I'm running into the same problem while working on a client. So |
Reading the code, I called |
We (Facebook networking team) have started working on adding handshake fragmentation support to mbedTLS. We are going to upstream the patch to the master repository once it is ready. |
that would be great! looking forward to it. would be super nice to also have it backported to 2.16 |
@oesh that will be wonderful!! I've been blocked by this for more than a year. How is your implementation going? Do you have a public dev branch that I might try? |
@bl4ck5un hey, I was busy with something else, but I am back to it. I do have a public dev branch, and it will be terrific to see early reports from the users. I will post an update here once I have something that passes tests, probably in the course of the following two weeks. |
@rojer I am starting with |
Sharing some of the design considerations. Please comment as appropriate. Memory managementMbedTLS expects the handshake message to be in I see several design alternatives, from the simplest to the more complicated. All assume a new config constant, SimplestThe simpler alternative is to increase the Advantages
Disadvantages
Agressive memory footprint optimizationInstead of passing Advantages
Disadvantages
KISS (for now)Considering the above alternatives, I am opting for the simpler alternative for the time being. My reasoning is:
Edit: adjusted the design alternatives to the |
Any progress? Call on my IoT STM32 device:
and got the error:
|
Update: Support for fragmented TLS handshake messages is ready for a merge into the In the meantime, the implementation is available in https://github.com/oesh/mbedtls/tree/hs_fragmentation__design_doc If you want to try this out:
|
Update - I have asked the MbedTLS community whether there's any issue with backporting the feature to 2.16. The response was that since this is not a bug fix, it would be best to not risk the stability of the long-term-support versions: https://lists.trustedfirmware.org/pipermail/mbed-tls/2020-October/000205.html |
fwiw, Cesanta agreed to open source our mbedtls modifications, among them i have incoming handshake message defragmentation - mongoose-os/mbedtls@097ccf2 this is against 2.16, and to complete the work fragmentation of outgoing messages is required. i do plan to finish this work at some point, but no firm ETA. |
Hi all, any updates on this issue above? It seems like message fragmentation is becoming more and more common and going to be problem for IoT devices to not have support for this. |
I've finished work mentioned in #1840 (comment) and we've had these changes in production for more than a year. As part of rebasing to 3.x i've now forward-ported the changes to 3.x and put up #8981. Feedback/test reports would be appreciated. |
This may often happen when TLS server sends certificates in different and sequential packets. We can use Though I have solved this issue in my personal project(https://github.com/zliucd/TLSfeat), but why fragmentation happens is still unknown. |
wdym unknown? handshake fragmentation happens because it is being requested by the client. |
Meta is using handshake fragmentation now. The TLS handshakes with https://www.facebook.com/ and https://www.instagram.com with mbedtls 3.6.2 as client are failing for me with |
@hauke they shouldn't be doing that if you don't ask for max fragment size. make sure you don't set max frag size. |
Meta is not violating rfc8446. A server is allowed to send fragmented handshake messages.
I do not know why they are doing it. |
Fragmentation saves back-forth packet data, but it's hard to tell the cause.
When you look into TLS code, there is literally no switch to turn on/off
fragmentation. I guess it's mostly caused by TCP control.
Hauke Mehrtens ***@***.***> 于2024年12月23日周一 23:56写道:
… Meta is using handshake fragmentation now. The TLS handshakes with
https://www.facebook.com/ and https://www.instagram.com with mbedtls
3.6.2 as client are failing for me with TLS handshake fragmentation not
supported. Is there a workaround to prevent Meta and others from using
handshake fragmentation?
—
Reply to this email directly, view it on GitHub
<#1840 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AVH54D6QFAW3JEGO7DGRQED2HAXCBAVCNFSM6AAAAABUDJDLW6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNJZHE2DINBQHE>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
I can reproduce the problem, as explained here: #9861 (comment) - increasing the debug level confirms that the client is not sending a I'm afraid I can't see any workaround. I think we'll need to implement support for this. I'll note there has been two PRs about that: #3817 and #8981 but none of them are in a good shape right now. We'll need to pick one to revive and complete (or create a new one). This is unlikely to be done by team members in the coming days considering most of us are or will soon be on holiday. Note: we usually have a policy of not backporting new features (which, technically, this would be) to LTS branches, but I'm strongly inclined to make an exception here and backport this to the 3.6 branch at least. |
Things that might be worth trying out (I have no time at the moment):
|
@mpg i can confirm TLS1.2 is a valid workaround:
|
To follow this important ticket |
I have a server setup that sends handshake with
ssl->in_hslen
set to above 22700-ish, which is above the accepted limit of 16384. Is there any plan to support this (or a workaround without changing the server) and if not, I would appreciate some tips as to how to implement this as it is quite urgent for my project.This is the code segment that fails:
/* With TLS we don't handle fragmentation (for now) */ if( ssl->in_msglen < ssl->in_hslen ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "TLS handshake fragmentation not supported" ) ); return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE ); }
The text was updated successfully, but these errors were encountered: