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

Error: The connection was closed on the transport level with error invalid certificate by the local endpoint #2300

Open
zoujiaqing opened this issue Aug 15, 2024 · 1 comment

Comments

@zoujiaqing
Copy link

Run examples code and generate pem

openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes -subj "/CN=localhost"

use this pems run this example:
https://github.com/aws/s2n-quic/tree/main/examples/rustls-provider

error:

Error: The connection was closed on the transport level with error invalid certificate by the local endpoint
@Tahinli
Copy link

Tahinli commented Mar 1, 2025

Hi,

I know this issue is open for long but I wanted to serve a solution.

You have to trust the certificate that server provides. For this you should enable tls for client too with the same certificate the server has. Here is an example:

let server = Server::builder()
        .with_io("127.0.0.1:4585")
        .unwrap()
        .with_tls((
            Path::new("certificates/cert.pem"),
            Path::new("certificates/key.pem"),
        ))
        .unwrap()
        .start()
        .unwrap();

let client = Client::builder()
        .with_io("127.0.0.1:0")
        .unwrap()
        .with_tls(Path::new("certificates/cert.pem"))
        .unwrap()
        .start()
        .unwrap();

Be careful I gave same certificate for client and server but only server has private key.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants