Instantiate a new CA certificate with a given private key and pem cert.
(pem_cert: String, pem_key: String)
| 44 | impl CaCert { |
| 45 | /// Instantiate a new CA certificate with a given private key and pem cert. |
| 46 | pub fn new(pem_cert: String, pem_key: String) -> Result<Self> { |
| 47 | let key = KeyPair::from_pem(&pem_key).context("Failed to parse key")?; |
| 48 | let cert = |
| 49 | CertificateParams::from_ca_cert_pem(&pem_cert).context("Failed to parse cert")?; |
| 50 | // TODO: load the cert from the file directly, blocked by https://github.com/rustls/rcgen/issues/274 |
| 51 | let cert = cert.self_signed(&key).context("Failed to self-sign cert")?; |
| 52 | Ok(Self { |
| 53 | pem_cert, |
| 54 | cert, |
| 55 | key, |
| 56 | }) |
| 57 | } |
| 58 | |
| 59 | /// Instantiate a new CA certificate with a given private key and pem cert. |
| 60 | pub fn from_parts(key: KeyPair, cert: Certificate) -> Self { |
nothing calls this directly
no test coverage detected