How can I use cloudflare's origin certificate with rust axum server?

80 views Asked by At

I have little server that is running on axum. For this server I need to setup full(strict) tls encryption. I have downloaded origin certificate and key. Then I saved them as cert.pem and key.rsa . After that I wrote this code: `let ip = IpAddr::from(Ipv4Addr::from_str(&config.server.ip).unwrap());

let addr = SocketAddr::new(ip, config.clone().server.port);

let tls_config = RustlsConfig::from_pem_file(config.clone().server.cert_path, config.clone().server.key_path).await.unwrap();

axum_server::tls_rustls::bind_rustls(addr, tls_config).serve(routes.into_make_service_with_connect_info::<SocketAddr>()).await.unwrap();`

Config looks like Server: {ip: 127.0.0.1, port: 443, cert_path: "cert.pem", key_path: "key.rsa"} Also I checked with code that cert.pem and key.rsa can be found and readen

So after I open my server with browser it shows me this error: SSL handshake failed Error code 525 Is there any way to solve this?

0

There are 0 answers