Skip to content

Can't use a self-signed certificate without using danger_accept_invalid_certs #1554

@mrcz

Description

@mrcz

I'm trying to POST to an external http server which uses a self signed certificate. I have put this certificate in a PEM file that I read using Certificate::from_pem and pass to Client::builder(). This worked on macOS using native TLS, but after I switched to rustls-tls I need to also call (on both macOS and Linux):

Client::builder()
    // ...
    .add_root_certificate(config.server_certificate)
    .danger_accept_invalid_certs(true)      // <- required with rustls-tls
    .use_rustls_tls();                      // <- required with rustls-tls

Why is this? I don't want to accept invalid certificates, just trust the provided server certificate. (There is no chain of certificates, just one)

The error I get is:

source: hyper::Error(Connect, Custom { kind: Other, error: Custom { kind: InvalidData, error: InvalidCertificateData("invalid peer certificate: UnknownIssuer") } })

Metadata

Metadata

Assignees

No one assigned

    Labels

    B-upstreamBlocked: upstream. Depends on a dependency to make a change first.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions