How to apply certificates for rust warp?

76 Views Asked by At

I attempted to applying certificates for my server using warp, but compiler return thread 'main' panicked at 'error binding to 127.0.0.1:3030: certificate parse error', /home/hjson96/.cargo/registry/src/index.crates.io-6f17d22bba15001f/warp-0.3.6/src/server.rs:550:27 when using certificates. What is the problem?

Here is my code snippet.

use warp::Filter;

#[tokio::main]
async fn main() {
    let routes = warp::any().map(|| "Hello, World!");

    warp::serve(routes)
        .tls()
        .cert_path("server.cer")
        .key_path("server.key")
        .run(([127, 0, 0, 1], 3030))
        .await;
}

For your information, this key pair was used well in other proxy server so maybe I think the format is not an issue. Then why this parsing error occurs? Let me know some possible reasons of this error.

0

There are 0 best solutions below