-
Notifications
You must be signed in to change notification settings - Fork 0
Add support for mbedtls to rust-native-tls #1
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
base: master
Are you sure you want to change the base?
Conversation
f6beddf
to
85c8540
Compare
8aaab8e
to
f82fd4f
Compare
Box::from_raw(self.config); | ||
Box::from_raw(self.rng); | ||
Box::from_raw(self.entropy); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe if !self.cred_cert_list.is_null()
?
src/imp/mbedtls.rs
Outdated
let trust_roots = if builder.root_certificates.len() > 0 { | ||
builder.root_certificates.clone() | ||
} else { | ||
load_ca_certs("/usr/share/ca-certificates/mozilla")? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to imply that this only works on *nix systems, so the mbedtls feature should only be available on those systems.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already Unix specific since on Windows and macOS/iOS rust-native-tls always uses the platform native APIs. Actually not just Unix specific but Ubuntu specific, as the location of the trust roots varies. This is just where Ubuntu sticks them.
So I guess this can be improved somewhat - first try several commonly used paths so things nominally work on RHEL etc. If none of the paths work, return an error telling the user they must provide the trust roots manually.
This PR is not for merging to this branch but just for review/commentary before I try opening a PR with upstream. There is a lot of unsafe, a lot of raw pointer manipulation in here. I do not believe upstream will take this PR as is.
I certainly think the rust-mbedtls API could be improved, such that it would be possible to implement this without all the unsafe. This would of course benefit any other current or potential users. See fortanix/rust-mbedtls#4. However I have no idea how to go about fixing our crates API. Suggestions very welcome.