hyperium / hyper-tls

Apache License 2.0
187 stars 96 forks source link

How to disable certificate verification for https client #109

Closed wpeng102 closed 7 months ago

wpeng102 commented 7 months ago

I am using hyper-tls library to build a https client and meet hyper::Error(Connect, Custom { kind: Other, error: Custom { kind: InvalidData, error: InvalidCertificate(UnknownIssuer) } }) error when using it to access a existing system via token.

We only have token for the client side, does the client can turn off certificate checking? Do we have any example for how to disable certificate verification.

Following is my code:

 let https_connector = TimeoutConnector::new(
        hyper_rustls::HttpsConnectorBuilder::new()
            .with_native_roots()
            .https_only()
            .enable_all_versions()
            .build(),
    );

    let https_client = Client::builder().build::<_, hyper::Body>(https_connector);
    let uri =
        "my_url".parse::<Uri>()?;
    let req = hyper::Request::builder()
        .method(Method::GET)
        .uri(uri)
        .header(CONTENT_TYPE, "application/json")
        .header(AUTHORIZATION, "my_token".to_string())
        .body(Body::from(String::new()))?;
wpeng102 commented 7 months ago

It should be my code issue, close this ticket.

joebnb commented 7 months ago

It should be my code issue, close this ticket.

im facing same issue,the document nothing valueable for this,would you share some code with the following

dswij commented 7 months ago

@joebnb The snippet is using hyper_rustls. Try asking around at https://github.com/rustls/hyper-rustls