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

Create Hyper HttpsConnector<SocksConnector<HttpConnector>> with self signed certificate #12

Open
Masber opened this issue Jul 2, 2023 · 3 comments

Comments

@Masber
Copy link

Masber commented Jul 2, 2023

Hi,

I have an HTTPS server with a self-signed certificate and my goal is to create a Hyper client using a HttpsConnector<SocksConnector<HttpConnector>> connector.

Dependencies:

hyper-socks2 = { version = "0.7.0", default-features = false, features = ["hyper-tls"] }

Then I do like this:

        let https_http_connector = config.rustls_https_connector()?;
        let mut http_connector = hyper::client::HttpConnector::new();
        http_connector.enforce_http(false);
        let socks_https_http_connector = SocksConnector {
            proxy_addr: std::env::var("SOCKS5").unwrap().parse::<Uri>().unwrap(), // scheme is required by HttpConnector
            auth: None,
            connector: https_http_connector.clone(),
        };
        // create HttpsConnector ????
        // inject server, CA and client certs ????

I noticed the hyper-tls feature does not provide the with_tls function.

But I don't know how to create HttpsConnector from the SocksConnector and inject the server, CA, and client certificate, any hints?

thank you very much

@ark0f
Copy link
Owner

ark0f commented Jul 2, 2023

I noticed the hyper-tls feature does not provide the with_tls function.

You must use tls feature which is enabled by default, so with_tls function will be provided

@Masber
Copy link
Author

Masber commented Jul 2, 2023

ok, and how could I inject the CA root cert and the client cert (mutual TLS) into the HttpsConnector?

@ark0f
Copy link
Owner

ark0f commented Jul 13, 2023

let socks_connector = SocksConnector { ... };
let tls_connector = native_tls::TlsConnector::builder()
    .add_root_certificate(...)
    .build()?;
let https_connector = HttpsConnector::from(socks_connetor, tls_connector);

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

No branches or pull requests

2 participants