(
ca_cert_file: &str,
ca_key_file: &str,
)
| 35 | } |
| 36 | |
| 37 | async fn get_ca_cert( |
| 38 | ca_cert_file: &str, |
| 39 | ca_key_file: &str, |
| 40 | ) -> Result<(String, Issuer<'static, KeyPair>)> { |
| 41 | let ca_cert_s = fs::read_to_string(ca_cert_file) |
| 42 | .await |
| 43 | .context("Read gateway ca_cert")?; |
| 44 | let ca_key_s = fs::read_to_string(ca_key_file) |
| 45 | .await |
| 46 | .context("Read gateway ca_key")?; |
| 47 | let ca_key_s = private_key_to_pkcs8(&ca_key_s)?; |
| 48 | let ca_key_algo = read_algo(&ca_cert_s)?; |
| 49 | |
| 50 | let ca_key = |
| 51 | KeyPair::from_pem_and_sign_algo(&ca_key_s, ca_key_algo).context("Parse gateway CA key")?; |
| 52 | |
| 53 | Ok(( |
| 54 | ca_cert_s.clone(), |
| 55 | Issuer::from_ca_cert_pem(&ca_cert_s, ca_key)?, |
| 56 | )) |
| 57 | } |
| 58 | |
| 59 | // This returns the CA, certificate and private-key as PEM encoded strings. |
| 60 | pub async fn client_cert_for_gateway_id( |
no test coverage detected