How to use existing certificate file for my https server?

⚓ Rust    📅 2025-06-26    👤 surdeus    👁️ 6      

surdeus

Warning

This post was published 44 days ago. The information described in this article may have changed.

I have two *.crt files named cert.crt and key.crt.
To use these files I imported these files and converted to rcgen::Certificate and rcgen::KeyPair type.
After converting, I printed certificate detail and it was different with original certificate.
How to fix this problem?

        let param = rcgen::CertificateParams::from_ca_cert_pem(
            &std::fs::read_to_string(&external_cert.cert).unwrap(),
        )
        .unwrap();
        let key_pair =
            rcgen::KeyPair::from_pem(&std::fs::read_to_string(&external_cert.private_key).unwrap())
                .unwrap();

        let cert = param.self_signed(&key_pair).unwrap();

2 posts - 2 participants

Read full topic

🏷️ rust_feed