-
Notifications
You must be signed in to change notification settings - Fork 155
Added HttpsConnector::new function #301
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: main
Are you sure you want to change the base?
Conversation
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.
Seems pretty reasonable to me. Thanks!
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.
Hmm, I'm inclined to add a method for this to the builder instead of adding yet another From
impl. Tuples get a bit unwieldy and this isn't quite a full solution since it doesn't support force_https: true
, for example.
Suggestions how? The missing method in the builder, is to use an |
Actually, it looks like you can already do this? The |
Yeah, but the builder doesn't accept a TlsConfig with a predefined alpn_protocols. Thats, at least to me, the main use of the From implementation that exists already. |
Just for my understanding, why do you need/want to set |
Actually, I just want to set the server_name_resolver on reqwest (a crate which uses hyper-rustls). I made a draft pr here: seanmonstar/reqwest#2708 . Reqwest sets alpn_protocols it self (and does also allow the user to set a custom ClientConfig with alpn_protocols already set, see https://github.com/seanmonstar/reqwest/blob/8cf142bd1f1722a1728a89af21747260bb993294/src/async_impl/client.rs#L2018 ). For this it uses the current From implementation, which I can't use in combination with the server_name_resolver. |
I guess that just moves the question to, why do you want a custom Looks like downstream doesn't necessarily like this solution anyway... |
I won't go into much detail, but I have a project (not public, yet) in which there is like a central controlling server and some clients (which also kinda act as servers). The central server is able to communicate with the "clients" via https (the clients host the https server). They are publicly reachable. As authentication on both sites, there is an ca certificate. The central server has one for "client authentication" and each client has one for "server authentication". The certificate doesn't have the actual dns name or ip address in it, but instead the database id (which is used on the central server) it should get verified against. |
Also, does the extra From implementation in the codebase really hurt that much? |
It does not hurt that much -- but it's not great API in the first place and we're potentially stuck with it for a long time, so I'd rather be careful about adding public API. And given that it's not yet clear how reqwest might accomodate your use case, we probably want for that to become more clear. |
As an alternative, how would be a impl<H> HttpsConnector<H> {
pub fn new(http: H, tls_config: impl Into<Arc<rustls::ClientConfig>>, force_https: bool, server_name_resolver: Arc<dyn ResolveServerName + Send + Sync>) -> Self {
Self {
http,
tls_config: tls_config.into(),
force_https,
server_name_resolver,
}
}
} instead of the From implementation? (ofc I will write rustdoc for the method then etc., also haven't tested the snippet, just as a proposal) |
Yeah, I'd be more comfortable with that (which I'm aware might be silly). |
As you can see here ,
HttpsConnector implements
which just sets the server_name_resolver to
DefaultServerNameResolver
.This adds
which does the same, but can be used to specify another server_name_resolver.