Skip to content

Implement support for Rustls - v2#725

Merged
jaymell merged 19 commits intoredis-rs:mainfrom
rharish101:rustls
Mar 31, 2023
Merged

Implement support for Rustls - v2#725
jaymell merged 19 commits intoredis-rs:mainfrom
rharish101:rustls

Conversation

@rharish101
Copy link
Copy Markdown
Contributor

@rharish101 rharish101 commented Nov 24, 2022

This PR takes over #601.

I've rebased @LeoRowan's PR onto the latest main. Then, I took @djc's suggestions about the feature flags, and did the following:

  • Rustls features:
    • Rustls support is added under the tls-rustls feature flag.
    • Insecure TLS connections are permitted with Rustls using the tls-rustls-insecure feature flag.
    • Rustls can be instructed to use Mozilla's root certificates using the tls-rustls-webpki-roots feature flag.
  • Rustls support for async I/O:
    • Tokio Rustls support is added under the tokio-rustls-comp feature flag.
    • async-std Rustls support is added under the async-std-rustls-comp feature flag.
  • Renames for native-tls (deprecation of older features):
    • The native-tls feature flag has been renamed from tls to tls-native-tls (for lack of a better naming scheme that's consistent with Rustls).
    • The async-std + native-tls feature flag has been renamed from async-std-tls-comp to async-std-native-tls-comp (for consistency).
    • Both of the older flags are retained for backwards-compatibility, with deprecation notices in the README and in Cargo.toml.

I've also documented how to use the Rustls feature flags in the README.

Closes #601 and resolves #574.

@rharish101 rharish101 marked this pull request as draft November 25, 2022 00:58
@rharish101 rharish101 marked this pull request as ready for review November 25, 2022 01:34
@djc
Copy link
Copy Markdown
Contributor

djc commented Dec 2, 2022

Thanks for picking this up! Hope to be able to review this soon.

@rharish101
Copy link
Copy Markdown
Contributor Author

rharish101 commented Dec 2, 2022

I just fixed a bug (a misconfiguration in the x509v3 extensions file for generating TLS certs used in testing) causing the Redis cluster tests to hang forever. All tests now pass on my machine. Could you run the CI again?

@0xAlcibiades
Copy link
Copy Markdown

This is exciting. Would like to use here: valorem-labs-inc/quay#41 - just saw this PR, serendipitous, because I'm trying to converge everything on tokio/rustls for sqlx, redis, http, grpc, etc.

@arnaudpoullet-dkt
Copy link
Copy Markdown

Nice! I hope to see this merged soon as well to remove openssl completely from our work project 🚀

@gd87429
Copy link
Copy Markdown

gd87429 commented Feb 9, 2023

Is there an ETA on this merge?

@djc
Copy link
Copy Markdown
Contributor

djc commented Feb 10, 2023

Nope, sorry. @rharish101 would you mind rebasing this once more?

@rharish101
Copy link
Copy Markdown
Contributor Author

@djc Done 👍🏽

@stevethedev
Copy link
Copy Markdown

I'm checking in to see if there's any movement on rustls support.

@PeterGrace
Copy link
Copy Markdown

Hi @djc , @rharish101 , what can I do to help get this PR merged? I'd like to use this crate in a project that cannot use openssl.

@djc
Copy link
Copy Markdown
Contributor

djc commented Mar 14, 2023

I'll take a look at it tomorrow -- sorry for the slow response.

@rharish101
Copy link
Copy Markdown
Contributor Author

Hi @djc , @rharish101 , what can I do to help get this PR merged? I'd like to use this crate in a project that cannot use openssl.

From my side, I don't think there's anything that needs to be done before code review, apart from rebasing the PR when asked. Let me know if I'm wrong, though.

Copy link
Copy Markdown
Contributor

@djc djc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking pretty good to me -- apologies again for the slow review!

Comment thread redis/Cargo.toml Outdated
@rharish101
Copy link
Copy Markdown
Contributor Author

rharish101 commented Mar 18, 2023

Just rebased it, fixed tests, and made Rustls use native certs by default. The tests pass on my machine, so if the CI says it's good, feel free to merge it.

@rharish101
Copy link
Copy Markdown
Contributor Author

rharish101 commented Mar 19, 2023

The failing tests seem odd. The error seems like a correctness bug, not a TLS connection issue (as you might expect from this PR). It's also only for one specific configuration, which I cannot reproduce locally (on Arch Linux, with Rust 1.68.0, Redis 7.0.9 and Redis-JSON 2.2.0).

@jaymell
Copy link
Copy Markdown
Contributor

jaymell commented Mar 19, 2023

Likely test flakiness, re-running

@rharish101
Copy link
Copy Markdown
Contributor Author

Great, they work now. Thanks!

@henrysun007
Copy link
Copy Markdown

Will this PR be merged soon? Eager to use the rustls support.

Comment thread redis/Cargo.toml
@jaymell
Copy link
Copy Markdown
Contributor

jaymell commented Mar 30, 2023

@rharish101 Do you mind resolving the conflict? 🙏

- Fixed syntax such that it's supported by the MSRV
- Renamed "tls" to "tls-native-tls"
- Renamed "rustls" to "tls-rustls"
- Renamed "rustls-insecure" to "tls-rustls-insecure"
- Renamed "async-std-tls-comp" to "async-std-native-tls-comp"
Rustls only accepts x509v3 certs, hence update the code to generate
x509v3 certs for the redis server.
The bug also exists in `main`
Also add deprecation notice for older features
@rharish101
Copy link
Copy Markdown
Contributor Author

I've rebased the PR onto the latest main 👍🏽

@djc
Copy link
Copy Markdown
Contributor

djc commented Mar 30, 2023

(Might be worth noting that rustls 0.21 has come out, but there are no matching tokio-rustls/webpki-roots versions quite yet.)

@rharish101
Copy link
Copy Markdown
Contributor Author

(Might be worth noting that rustls 0.21 has come out, but there are no matching tokio-rustls/webpki-roots versions quite yet.)

If there are libraries that haven't been updated with the new Rustls, then I think it would be better to merge this PR and update Rustls in a new PR, rather than wait for them and update this PR.

@jaymell
Copy link
Copy Markdown
Contributor

jaymell commented Mar 30, 2023

I'm a bit worried that, as is, our test runs will not be hitting native-tls at all with the current configuration, correct? I hate to keep adding more jobs, but I think it's probably worth it in this case.

@rharish101
Copy link
Copy Markdown
Contributor Author

Oh yeah, good catch. I'll work on it.

@jaymell
Copy link
Copy Markdown
Contributor

jaymell commented Mar 30, 2023

Thanks. And sorry "jobs" was not the right terminology. I was thinking in terms of Github CI for some reason, but obviously I think the solution is to add yet another run to the Makefile 😓

@rharish101
Copy link
Copy Markdown
Contributor Author

Test flakiness, perhaps, since the failing test is for RedisJSON, which wasn't changed at all.

@jaymell jaymell merged commit 7eab4cf into redis-rs:main Mar 31, 2023
@jaymell
Copy link
Copy Markdown
Contributor

jaymell commented Mar 31, 2023

Merged. Thanks for bringing this to the finish line!

@rharish101 rharish101 deleted the rustls branch March 31, 2023 05:44
@jonasms
Copy link
Copy Markdown

jonasms commented Oct 20, 2023

Folks, thank you for this work AND please update the features section of the docs when you add features!

barshaul pushed a commit to barshaul/redis-rs that referenced this pull request Jul 11, 2024
Add python/core support for configuring client name during connection…
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feautre request: support rustls