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

rustls: optionally use WebPKI roots to avoid panicking on Android & iOS #1323

Merged
merged 3 commits into from
Sep 29, 2024

Conversation

ewilken
Copy link
Contributor

@ewilken ewilken commented Oct 24, 2023

Motivation

Using kube-rs on iOS, I came across a panic in the underlying hyper-rustls root cert initialization trying to access the native roots, which doesn't work on Android or iOS, according to this open issue.

Solution

My solution was to add a check to fall back to the WebPKI roots when on Android or iOS, which fixes the issue for me, but could make sense upstream, too.

Please let me know if this change makes sense to you or whether I'm missing anything. And thanks a lot for all the work you've done on the kube-rs ecosystem! 😊

@clux
Copy link
Member

clux commented Oct 25, 2023

Hey, thanks for this!

I do think this, or some variant of this makes sense, and am happy to include a variant of this. The few bits i am sceptical of atm are:

  • default inclusion - as this would be a new dep for everyone, even though we use native roots elsewhere
  • magic inference - it's probably better to let users choose this rather than bake in this (particularly as it gives the impression we test iOS/android which we dont)

There are two alternatives I think;

  1. make an explicit feature for it so people can choose this option if they want to in general
  2. try to do some [target.cfg...] magic in Cargo.toml

I think 1. makes the most sense, but it might be hairier to make a feature for this? At the very least reqwest has a quite hairy feature selection setup to get all the things exposed.

@codecov
Copy link

codecov bot commented Oct 25, 2023

Codecov Report

Attention: Patch coverage is 20.00000% with 4 lines in your changes missing coverage. Please review.

Project coverage is 75.3%. Comparing base (bb9a44e) to head (f5c33fe).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
kube-client/src/client/tls.rs 0.0% 3 Missing ⚠️
kube-client/src/client/auth/oauth.rs 0.0% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main   #1323     +/-   ##
=======================================
- Coverage   75.3%   75.3%   -0.0%     
=======================================
  Files         82      82             
  Lines       7328    7331      +3     
=======================================
  Hits        5515    5515             
- Misses      1813    1816      +3     
Files with missing lines Coverage Δ
kube-client/src/client/auth/oidc.rs 56.1% <100.0%> (-0.3%) ⬇️
kube-client/src/client/auth/oauth.rs 0.0% <0.0%> (ø)
kube-client/src/client/tls.rs 79.6% <0.0%> (-0.9%) ⬇️

@ewilken
Copy link
Contributor Author

ewilken commented Oct 25, 2023

Makes sense. Happy to try out either one of the two scenarios!

But is the failing CI check about webpki-roots bringing in an MPL-2.0 license a show-stopper?

@clux
Copy link
Member

clux commented Oct 25, 2023

MPL-2.0

It shouldn't be a problem. Particularly if it's an opt-in feature, as then it's up to users whether they want the stricter license the transitive dependency comes with.

@clux
Copy link
Member

clux commented Oct 25, 2023

Given we want opt-in for many reasons, i think if we add a feature for it in kube-client/Cargo.toml:

webpki-roots = ["hyper-rustls/webpki-roots"]

plus re-export it from kube/Cargo.toml (i.e. feature in kube crate needs to enable kube-client/webpki-roots).

then we should be good.

we would need a licenses.clarify entry in deny.toml (see docs) about this license being excluded because it is an optional feature.

@ewilken
Copy link
Contributor Author

ewilken commented Oct 26, 2023

Gotcha. Do you think the feature should gate the current check to use WebPKI roots only on Android and iOS, or just alternate between native and WebPKI roots on every platform by setting the feature flag? My gut feeling is the latter is probably the cleaner thing to do and less confusing for an API consumer.

@ewilken ewilken changed the title rustls: use WebPKI roots on Android & iOS rustls: optionally use WebPKI roots to avoid panicking on Android & iOS Oct 26, 2023
@ewilken ewilken marked this pull request as draft November 10, 2023 13:08
@ewilken ewilken closed this Sep 28, 2024
@ewilken
Copy link
Contributor Author

ewilken commented Sep 28, 2024

Sorry it went quiet here for so long. Trying to give this another go now. cargo-deny seems to be happy even without a licenses.clarify, but please let me know if I got anything wrong on that end.

@ewilken ewilken reopened this Sep 28, 2024
@ewilken ewilken marked this pull request as ready for review September 28, 2024 10:36
Copy link
Member

@clux clux left a comment

Choose a reason for hiding this comment

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

I think this generally looks good. I had also forgotten about this. Two minor suggestions.

kube-client/src/client/tls.rs Show resolved Hide resolved
deny.toml Outdated Show resolved Hide resolved
@clux clux added the changelog-add changelog added category for prs label Sep 28, 2024
@clux clux added this to the 0.96.0 milestone Sep 28, 2024
clux added a commit to kube-rs/website that referenced this pull request Sep 28, 2024
for kube-rs/kube#1323 when it releases

Signed-off-by: clux <[email protected]>
@clux clux merged commit 27a2129 into kube-rs:main Sep 29, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog-add changelog added category for prs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants