Skip to content
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

Rust crypto: rustls (+ ring) vs openssl #1254

Closed
tiziano88 opened this issue Jul 10, 2020 · 8 comments
Closed

Rust crypto: rustls (+ ring) vs openssl #1254

tiziano88 opened this issue Jul 10, 2020 · 8 comments
Assignees
Labels

Comments

@tiziano88
Copy link
Collaborator

Currently we are using rustls, mostly for convenience in the build process (especially under the musl target).

I think we should be more intentional in the choice of such a fundamental crypto library though. I haven't looked at either option closely, but it feels at some point we should investigate this and decide which one we are comfortable using, and then figure out a way of actually get it to compile.

In addition to the build issues, other issues that came up are whether IP addresses are supported for TLS certificates, though I don't think we should make a decision on the basis of this (unless we end up really being indifferent about the two options otherwise)

ref

@daviddrysdale you are probably in the best position to advise on this, so I hope you don't mind me assigning to you to investigate and come to a conclusion (then we can do the actual work of migrating, if any, separately), and giving it a high priority (but feel free to dial it down if you think it does not fit in your planning).

cc @benlaurie FYI

@daviddrysdale
Copy link
Contributor

@conradgrobler, it sounded like you'd found things out about tonic and its (more recent) dependencies – could you summarize?

@daviddrysdale
Copy link
Contributor

@conradgrobler
Copy link
Collaborator

Earlier versions of Tonic supported using either rustls or OpenSSL, but they have recently decided to only support rustls directly (hyperium/tonic#141). It should still be possible to use other options via additional crates (eg https://lib.rs/crates/tonic-openssl) or configuring the TLS at the hyper level rather than using the Tonic convenience wrappers.

@daviddrysdale
Copy link
Contributor

So IIUC:

  • The current dep graph is roughly that Oak uses:
    • tonic for gRPC support, which uses:
      • tokio-rustls to make TLS streams accessible in tokio-land, which uses:
        • rustls for TLS support, which uses:
          • webpki for X.509 cert processing, and
          • ring for crypto operations, which uses:
            • BoringSSL for some of its underlying crypto primitives.
  • It should be possible to use different dependencies in the middle of that stack, but it would be a bunch of work.
  • The stack above seems to be well-respected, and we've only hit one snag with it (lack of support for IP addresses in X.509 certs).

Is that about right?

@conradgrobler
Copy link
Collaborator

I think that is about right, yes.

@daviddrysdale
Copy link
Contributor

BTW, the sleevi took a look at X.509 cert chain building recently, and wasn't keen on OpenSSL. The article didn't cover rustls/webpki, but a subsequent tweet had "When using webpki, no issues. When using native TLS, see above".

@tiziano88
Copy link
Collaborator Author

Thanks both for the write up and the links, it was really helpful (to me at least, given my ignorance).

I actually thought that rustls was a pure-Rust implementation from scratch, but it looks like it is actually a mix of Rust and C, and that the C comes actually from boringssl itself. This makes me much more comfortable with it. I am happy to close this issue, @daviddrysdale I'll leave that to you in case you have anything else to mention / check before we do.

@daviddrysdale
Copy link
Contributor

Yep, seems like rustls and its default stack is a sensible choice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants