-
Notifications
You must be signed in to change notification settings - Fork 3k
Cannot use TLSSocket without enabling MBEDTLS_SHA1_C macro #8638
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
Comments
Internal Jira reference: https://jira.arm.com/browse/MBOCUSTRIA-137 |
How much does |
I think this depends on the root certificate you provide TLSSocket. I'm able to connect to AWS S3 using TLSSocket out of the box and a SHA256 signed certificate. @janjongboom can you post the certificate you are trying to use? |
@marcuschangarm os.mbed.com See the code example in https://os.mbed.com/blog/entry/Adding-TLS-Sockets-to-Mbed-OS/ |
LetsEncrypt certificate work without this COMODO certificate seems to require this SHA1. |
Tried a build without the macro and using Mbed OS Socket example modified to TLS
With
So the flash size is affected by 5kB. This is now up to TLS team to decide whether to enable that macro by default or not. |
@SeppoTakalo @marcuschangarm Any idea on how we could print an error message to tell the user to enable this macro when we encounter this? If we could do that that'd be good by me. |
So it seems that SHA1 is required for old and weak certificates. And again, I should not make any statements on how Mbed TLS is built, or should build. CC: @ARMmbed/mbed-tls-gatekeepers can you comment here on how to handle this. Should we, or should Mbed TLS print out warning when building it with secure config. Feels a bit wrong... As what comes to runtime error code, turning on the traces would print out this:
That is pretty much all we can get from TLS library. |
Hello, I haven't investigated the issue(s) you're facing, but just to comment on The trace from |
Yes, the same certificate works if SHA1 is enabled. This was the error log:
This is when SHA1 is enabled:
Log outputs are coming from the wrapper layer, not from the Mbed TLS library. Is there some way to enable some loggings from TLS library as well? Should I re-run the same app with those enabled? edit: sorry, copy&pasted wrong logs.. but anyway those were similar. |
Both say that |
Since this is PKI, there is probably a certificate chain involved. All certificates in the chain would need to avoid SHA-1. Probably the root certificate for Let's Encrypt is |
In Mbed TLS, you can get logs by compiling it with
I don't know if the Mbed OS socket object has already done some of these steps for you. |
Ok, I checked https://api.ipify.org/, their certificate chain uses SHA-2 all the way to the root, but the root itself is self-signed with SHA-1. This is not a security problem since the signature of the root doesn't matter, but Mbed TLS still wants to verify that the signature is correct, and it needs SHA-1 for that. It's unnecessary for security to calculate a SHA-1 value in this scenario, but I don't know if there's a way to make Mbed TLS understand this. |
Based on @gilles-peskine-arm's analysis of the certificate chain, this is effectively by design because your root certificate is using SHA-1, therefore you need SHA-1. We may be able to remove it's use on the root certificate, but to me that sounds like an optimisation, not a bug. Or to put it another way, this is a limitation of the design. I haven't studied this issue beyond reading the thread, but the simple answer to @janjongboom is, if you don't want to build in SHA-1 into your image, make sure your entire certificate chain does not make use of SHA-1. I do not see this as a bug - and to follow what @gilles-peskine-arm says, is really an enhancement or feature request to the original design. As an aside - we're looking into completely redesigning the way configurations are made on Mbed TLS anyway. cc: @RonEld, @ndevillard |
In this case, it is a simple test app using If not going to make the optimisation in mbed TLS, and If we're going to give people an "easy-to-use" |
This is probably a terribly naive question, but why can't we fix the cert chain? Why this CA? Why this root? |
@sbutcher-arm But we don't control which CAs people use, and:
Is an unhelpful message with no indication that you need to enable something in your TLS config. And further I second @kjbracey-arm's message. If we're adding an API like this it should 'just work'. Like everything else in Mbed OS. Or provide very clear guidance if people need to enable certain ciphers. |
The problem seems to be that the X.509 OID for SHA-1 is defined only if I think that the OIDs should be known to the library even if the primitives themselves are not included. This would be in line with other parts of the library, e.g. all hash identifiers being defined in md.h even if the respective modules are not enabled. This comes at a slight additional cost of ROM, but importantly doesn't require setting |
Fishing for alternatives to increasing fixed table overhead. Why does the signature algorithm OID need to be recognised anyway if you're not going to process the signature? Could the OID lookup be deferred until the point you know you're checking it? Or, if it's parse first, process later, how about having a dummy "unknown" signature primitive that always fails operations? That could be assigned by the parser to defer error generation until the signature is used. |
@kjbracey-arm It should be possible to store the unparsed signature OID and defer parsing it to when the signature needs to be verified. However, it might be that the logic for this postponed parsing is larger in code than the OID table entries we're trying to eliminate - but this would need more careful evaluation. |
Yes, that could indeed be a cheaper alternative, with only a small code overhead. |
@janjongboom - Then Add SHA-1 back into the configuration for sample. Makes it bigger, but it will also make it work. |
I'm sorry, my comment is quite unrelated to the main issue here, but this log feels quite wrong to me: why doesn't it stop at the first error? As a matter of principle you should never attempt a handshake if anything went wrong while setting it up. This is bad security hygiene and could have very serious consequences if other errors are ignored. (For example, continuing after errors in your RNG setup voids any kind of security warranty.) To all Mbed TLS users: please always abort on the first error and do not attempt to initiate or continue a handshake after an error occurred. |
This is "user error" - it's the example application from ARMmbed/mbed-os-examples-docs_only#11 that fails to check the return code from Not sure we need to take any further action in But conceivably you could have a "save users from themselves" lock which basically "killed" the wrapper permanently whenever any mbed TLS (or transport?) error was spotted. I wouldn't be opposed to that, as long as there was a way to suppress the logic for the rare cases where you are expecting a potential error. |
@kjbracey-arm Thanks for the info! I agree the problem lies in the example application. Can you make sure it's fixed in the PR before it's merged? We want our examples to show good practices. In the longer run, I agree it could be a good idea to have a "save users from themselves" lock in the wrapper as you say, but you guys can think about it later. |
We closed this issue because it has been inactive for quite some time and we believe it to be low priority. If you think that the priority should be higher, then please reopen with your justification for increasing the priority. |
Uh oh!
There was an error while loading. Please reload this page.
Description
You cannot use TLSSocket in Mbed OS master without declaring
MBEDTLS_SHA1_C=1
in your macros section inmbed_app.json
. This is not good, everything should work out of the box. We should add it to the default TLS config, or add it to mbed_lib.json for TLSSocket (like it is in the standalone library).Issue request type
@bulislaw @SenRamakri @sg-
The text was updated successfully, but these errors were encountered: