Git Product home page Git Product logo

Comments (3)

djc avatar djc commented on May 28, 2024

What is the problem you're trying to solve? You're proposing a potential solution (which I don't completely understand) but I'd like to understand what your use case is.

from hyper-rustls.

ctz avatar ctz commented on May 28, 2024

How about

let tls: hyper_rustls::HttpsConnector = ...;
HttpsConnector::from((http_conn, tls))

from hyper-rustls.

dvaerum avatar dvaerum commented on May 28, 2024

Hey @ctz
Your suggestion sadly did not work, keep getting the error

Error
the trait bound `Arc<rustls::client::client_conn::ClientConfig>: From<HttpsConnectorBuilder<WantsProtocols3>>` is not satisfied [E0277]
the trait `From<HttpsConnectorBuilder<WantsProtocols3>>` is not implemented for `Arc<rustls::client::client_conn::ClientConfig>`
Help: the following other types implement trait `From<T>`: <Arc<std::ffi::OsStr> as From<OsString>> <Arc<std::ffi::OsStr> as From<&std::ffi::OsStr>>
<Arc<Path> as From<PathBuf>>
<Arc<Path> as From<&Path>>
<Arc<CStr> as From<CString>>
<Arc<CStr> as From<&CStr>>
<Arc<str> as From<std::string::String>>
<Arc<str> as From<&str>> and 7 others
Note: required for `HttpsConnectorBuilder<WantsProtocols3>` to implement `Into<Arc<rustls::client::client_conn::ClientConfig>>`
Note: required for `hyper_rustls::HttpsConnector<HttpConnector>` to implement `From<(HttpConnector, HttpsConnectorBuilder<WantsProtocols3>)>`

But it did make me look one more time, and then I found the function/method I was looking for, called wrap_connector.

use log::info;
use hyper_util::client::legacy::connect::{HttpConnector};
use hyper_rustls;

pub(crate) fn get_https_connector(
    network_interface: Option<String>
) -> hyper_rustls::HttpsConnector<HttpConnector> {
    let mut http_conn = HttpConnector::new();

    if let Some(network_interface) = network_interface {
        info!("Using network interface: {}", network_interface);
        http_conn.set_interface(network_interface);
    }

    let tls = hyper_rustls::HttpsConnectorBuilder::new()
        .with_native_roots().expect("no native root CA certificates found")
        .https_or_http()
        .enable_all_versions();

    let https_conn = hyper_rustls::HttpsConnectorBuilder::new()
        .with_native_roots().expect("no native root CA certificates found")
        .https_or_http()
        .enable_all_versions().wrap_connector(http_conn);

    https_conn
}

from hyper-rustls.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.