(self)
| 44 | |
| 45 | impl RaClientConfig { |
| 46 | pub fn into_client(self) -> Result<RaClient> { |
| 47 | let mut builder = Client::builder() |
| 48 | .tls_sni(true) |
| 49 | .danger_accept_invalid_certs(self.tls_no_check) |
| 50 | .danger_accept_invalid_hostnames(self.tls_no_check_hostname) |
| 51 | .tls_built_in_root_certs(self.tls_built_in_root_certs) |
| 52 | .connect_timeout(Duration::from_secs(5)) |
| 53 | .timeout(Duration::from_secs(60)); |
| 54 | if self.cert_validator.is_some() { |
| 55 | builder = builder.tls_info(true); |
| 56 | } |
| 57 | if let (Some(cert_pem), Some(key_pem)) = (self.tls_client_cert, self.tls_client_key) { |
| 58 | let identity_pem = format!("{cert_pem}\n{key_pem}"); |
| 59 | let identity = |
| 60 | Identity::from_pem(identity_pem.as_bytes()).context("Failed to parse identity")?; |
| 61 | builder = builder.identity(identity); |
| 62 | } |
| 63 | if let Some(ca) = self.tls_ca_cert { |
| 64 | let ca = Certificate::from_pem(ca.as_bytes()).context("Failed to parse CA")?; |
| 65 | builder = builder.add_root_certificate(ca); |
| 66 | } |
| 67 | let client = builder.build().context("failed to create client")?; |
| 68 | Ok(RaClient { |
| 69 | remote_uri: self.remote_uri, |
| 70 | pccs_url: self.pccs_url, |
| 71 | client, |
| 72 | cert_validator: self.cert_validator, |
| 73 | verify_server_attestation: self.verify_server_attestation, |
| 74 | }) |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | pub struct RaClient { |
no test coverage detected