-
Notifications
You must be signed in to change notification settings - Fork 83
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
Implement native-tls compatible APIs #3
Comments
One problem will be, Last year I worked on a project that used mbedtls that needed PKCS12, I hacked up something that happened to be able to generate valid PKCS12 files + parse them but it was fragile and (with mbedtls's quite primitive ASN1 library) very verbose, it was easily 1K lines of C. If PKCS12 support proves required (as I think it would be for |
This assumes it is safe to invoke a shared |
I'm clearly misunderstanding what |
Things missing that native-tls expects
Things that are missing but I think I can work around:
I think I will refactor my code so that the Also an issue:
|
128: MbedTLS Reference counted instead of lifetimes r=jethrogb a=AdrianCX Moving from referene counting allows simpler move to native-tls / hyper. Arc Changes: - Each Config/Context/... will hold Arcs towards items it holds pointers to. - This forces objects to live as long as needed, once no longer used they get destroyed by reference counting. This allows passing the objects to multiple threads without worrying about lifetime. I've also added notes why classes are Sync where used. Let me know if I missed any classes. Usage example of an intermediate mbed-hyper integration is at: - https://github.com/fortanix/rust-mbedtls/tree/acruceru/wip-mbed-hyper-v2/mbedtls-hyper/examples/integrations There I added a crate to wrap hyper - similar to native-tls. (that will be moved to native-tls layer soon) That crate can be considered an integration test that I will raise a separate PR for. Edit: Changes after initial review: - Added forward_mbedtls_calloc / forward_mbedtls_free functions so we can pass certificates to and from mbedtls without allocator mismatches/corruptions. - Switched to MbedtlsList<Certificate> and Certificate. A MbedtlsBox is pending for this PR as well. - Fixed most comments. Still pending: - Update define! macros - Add MbedtlsBox<Certificate> Fixes #1 Partial progress on #3 Fixes #4 Fixes #8 Partially addresses #9 Co-authored-by: Adrian Cruceru <adrian.cruceru@fortanix.com>
128: MbedTLS Reference counted instead of lifetimes r=jethrogb a=AdrianCX Moving from referene counting allows simpler move to native-tls / hyper. Arc Changes: - Each Config/Context/... will hold Arcs towards items it holds pointers to. - This forces objects to live as long as needed, once no longer used they get destroyed by reference counting. This allows passing the objects to multiple threads without worrying about lifetime. I've also added notes why classes are Sync where used. Let me know if I missed any classes. Usage example of an intermediate mbed-hyper integration is at: - https://github.com/fortanix/rust-mbedtls/tree/acruceru/wip-mbed-hyper-v2/mbedtls-hyper/examples/integrations There I added a crate to wrap hyper - similar to native-tls. (that will be moved to native-tls layer soon) That crate can be considered an integration test that I will raise a separate PR for. Edit: Changes after initial review: - Added forward_mbedtls_calloc / forward_mbedtls_free functions so we can pass certificates to and from mbedtls without allocator mismatches/corruptions. - Switched to MbedtlsList<Certificate> and Certificate. A MbedtlsBox is pending for this PR as well. - Fixed most comments. Still pending: - Update define! macros - Add MbedtlsBox<Certificate> Fixes #1 Partial progress on #3 Fixes #4 Fixes #8 Partially addresses #9 Co-authored-by: Adrian Cruceru <adrian.cruceru@fortanix.com> Co-authored-by: Jethro Beekman <jethro@fortanix.com>
I'm currently taking another stab at this, as we want to use mbedtls for our os (espidf). With the changes made since the first attempt you folks made, its been relatively clean to implement. The final hurdle are the quite strict trait bounds on As far as I understand it, these trait bounds are required because unlike the openssl crate, I assume it was done this way for a reason, but I don't know enough about the internals of mbedtls to understand why, hopefully you can help me out here. Would it be possible to drop the indirection and move the stream into the |
@xinyufort FYI |
note: making Context generic is also covered via pr: #163 |
Happy new year folks! :) Is there anything we can do to push this forward? Is @AdrianCX's PR suitable? Would it be possible to separate the generic context element of the PR into another, if other parts of the PR are blocking? I also see that there is another request for this in #178, seems this is also needed for use with the ureq library. |
To make sure it's easy for people to swap in MbedTLS where they were using some other TLS library before, we need to make sure
native-tls
could be implemented in terms of MbedTLS.The text was updated successfully, but these errors were encountered: