-
Notifications
You must be signed in to change notification settings - Fork 299
Add feature to use reqwest with rustls/webpki_roots #2811
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
Open
everest-boehm
wants to merge
6
commits into
Azure:main
Choose a base branch
from
everest-boehm:lb/reqwest_rustls_webpki_roots
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a734e93
Add feature to use reqwest with rustls/webpki-roots
everest-boehm 44e241e
Fix missing feature in azure_identity
everest-boehm bd9efc9
Do not auto-enable native-tls accidentally
everest-boehm 880fcad
Fix test
everest-boehm 75fc9b2
Merge remote-tracking branch 'upstream/main' into lb/reqwest_rustls_w…
everest-boehm ff5b1d8
More test fixes
everest-boehm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Similar to #2796, we cannot pull in a dependency on
ring
which I think this would do. Unfortunately, that's a hard blocker.Both of these PRs make me wonder if we just need to rethink our dependency on
reqwest
; rather, how we depend on it. Considering that resolver version >= 2 take a union of features in the dependency tree, why should we even get into the business of whichreqwest
feature we take? Obviously we need to optionally depend ongzip
anddeflate
for code we have, but the actual TLS features we don't have a hard dependency on. Maybe we should just avoid any such dependencies entirely; unless, of course, that pulls inring
by default. But considering that resolve v2+ doesn't support mutually exclusive features, we could still take a dependency onnative-tls-native-roots-no-provider
and people can depend on whatever other features they want inreqwest
, right? Would that actually work?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.
Thank you for having a look at this :)
I am not sure if you meant to comment on this line specifically or whether you commented on the goal of the PR in general. This line here is only renaming a feature of the
typespec_client_core
crate. There should not be any change in the pulled dependencies because of it. I think you could also check theCargo.lock
file's diff as (IIUIC) it should always include entries for all possible dependencies. For this PR, it is only extended with an entry forwebpki-roots
.I changed this feature's name because of a slightly weird (to me at least) cargo behavior: Cargo auto-enables an optional dependency when a feature from our crate is depending on a feature of the dependency (
crate/feature
syntax). However, it also will activate any feature of our crate with the name of the dependency while doing so.Concretely, this meant that when I want to build only with the
reqwest_rustls_webpki_roots
feature (which is the goal of my PR, i.e. not accidentally pulling inopenssl
as the native certs provider), I would need to enablereqwest/rustls-tls-webpki-roots-no-provider
, hence enabling thereqwest
dependency AND ourreqwest
feature, which was then enablingreqwest/native-tls
and thus breaking what I set out to do.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.
I'm not sure I fully understand what you're saying here. You're saying you have a feature named "reqwest" in your crate as well?
What I'm specifying here in
Cargo.toml
is that if you want to usereqwest
, we default to using the native TLS feature so that there's some TLS provided. I don't want to start getting into 1:1 parity with dependencies' feature names when a consumer can just as easily take a dependency onreqwest
themselves and enable whatever other features they want, since cargo's resolver v2 and newer takes a union of features and mutually exclusive features aren't supported.This is why I'm proposing that instead of adding more features (or even renaming), consumers can add a direct dependency to
reqwest
themselves and pass in their ownHttpClient
if they want, which we support fairly easily.We're not going to take this PR this week as we're about to release core and the other crates, but I want to do a little usability test to see if this is feasible. Our decision to provide a default but not required HTTP stack should not also require us on behalf of consumers to start doing 1:1 parity of dependencies' features. That will be difficult to maintain and difficult for consumers to use.
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.
With "our crate" I meant
typespec_client_core
. I'm only trying to point out the technical issue that when the feature is namedreqwest
like the dependency, any usage ofreqwest/some-feature
will enable thereqwest
feature (i.e. not only the dependency). And then - when thereqwest
feature is defined as["reqwest/native-tls"]
we pull inopenssl
on linux which is what I want to avoid.I get this and share the feeling a 100%. I was looking a bit if I can find out how others in the rust world deal with this. This gave me the impression that maybe people solve it over composition rather than dependencies? Might be totally off, though. Actually I was questioning if this wasn't already doable and I just hadn't thought of it. But I am worried about a couple of sprinkled calls to
new_http_client
fromsdk/typespec/typespec_client_core/src/http/clients/mod.rs
(especially inimpl Default for TransportOptions
). But maybe this is the direction to pursue, after all - i.e. only conditionally provide default construction of anything that needs an http client if a backend is explicitly enabled via a feature (which it would be bydefault
)I think that it could be better to express this by having
reqwest/native_tls
intypespec_client_core
'sdefault
features rather than in the overallreqwest
feature, though. That's what I was doing in this PR.No worries. I am also fine if we do not end up proceeding with the PR at all. Installing
openssl
into all our images was more a nuisance rather than a blocker for us. Naively I thought it was going to be a minor thing to fix. But I am starting to realize it very much is not 😄 Overall, I am really happy that I got attention from you for this "problem" and grateful for the time you have spent to give me feedback.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.
We do support composition - we have to, since 1P will not be using
tokio
for async, for example (which also rules outreqwest
built onhyper
) - but we still provide a default for the vast majority of consumers who either won't care, or will likely be usingtokio
/reqwest
as the almost de facto async/HTTP stacks. Therein lies the problem of dependencies. You can "disable"reqwest
and use your own stack and we shouldn't pull in anything.Given the behavior you noted - I had not noticed that myself but it doesn't surprise me - that indeed may be a good rename but, as noted, we won't take it for this imminent release.
Avoiding the unwanted
openssl
dependency is certainly justified. It's a pain to get on Windows, though I don't suspect many servers running Rust are probably running on Windows/Windows containers. Still, no reason to make acquisition and deployment harder.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.
Fair - I suppose
TransportOptions
can be specified in all relevant places with anyHttpClient
implementations users could come up with. I should try this out! Within the scope of this SDK I'm worried, however, thatnew_http_client
makes it a bit too easy to accidentally create APIs that just assume one can always be materialized from thin air. Am I mistaken here? Apologies for the silly question, but I actually do not know: In which use cases is falling back toNoopClient
desired behavior? Would it maybe be feasible to only makenew_http_client
(and all implementations of someimpl Default
using it) available if thereqwest
feature is active? I.e. without anyNoopClient
fallback, thus forcing correctHttpClient
provision?I found it a bit surprising that
openssl
would become a problem on windows - thenative_tls
crate's docs stateSo I would assume on windows it should not be part of the build-time dependencies(?).