-
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
Error when generating a certificate via mbedtls_x509write_crt_pem and then parsing it. #3682
Comments
Hi! Do you guys already have a potential patch that you think fixes this? If so, then do feel free to submit that for review. |
Hi, no actually, we added the aforementioned workaround in our code, using |
I agree that this is a bug. It's an unintended regression. I've posted a more detailed analysis in #3896. I think that we should relax the idiom for PEM parsing functions to require the input to be null-terminated, i.e. require that there is a null byte in the buffer, even if it isn't the last byte. However, we may also or alternatively change the writing functions to zero out the temporary data at the end of the buffer. The temporary data could cause other problems, such as a data leak after writing a private key, if the caller only wiped the first |
Hi @Faless. Thanks for your report, especially providing an example file which makes it very easy to reproduce the problem and understand what exactly is going on. And of course pointing to the PR that introduced the issue is appreciated! Also, sorry for not replying earlier - we usually try to give at least an initial reply within a few business days, but for some reason we appear to have missed this report. Regarding the issue, I agree that this is a change of observable behaviour in Regarding the resolution, I'm think we could make |
Oops, I failed to refresh the page before replying and didn't noticed that Paul and Gilles had already done so. |
About this topic and facilitating round trip; did someone write a support function such as?
THX if any. |
@Faless give away
|
Description
Bug
mbed TLS build:
Version: 2.16.8 (build statically, with GCC)
Due to the changes in #2632 (and its backport #3488), creating a PEM certificate via
mbedtls_x509write_crt_pem
, then reading it into ambedtls_x509_crt
viambedtls_x509_crt_parse
will fail when passing the full buffer size in2.16.8
while not failing in2.16.7
.(see example code below, compiled with
gcc example.c -I./build/include/ -Lbuild/library/ -lmbedtls -lmbedx509 -lmbedcrypto -Wl,-rpath,"build/library"
).The text was updated successfully, but these errors were encountered: