Add a certificate to the builder The domain is the base domain (e.g., "example.com"). All gateway certificates are wildcard certs for "*.{domain}".
(&mut self, domain: &str, data: &CertData)
| 238 | /// The domain is the base domain (e.g., "example.com"). |
| 239 | /// All gateway certificates are wildcard certs for "*.{domain}". |
| 240 | pub fn add_cert(&mut self, domain: &str, data: &CertData) -> Result<()> { |
| 241 | let certified_key = parse_certified_key(&data.cert_pem, &data.key_pem) |
| 242 | .with_context(|| format!("failed to parse certificate for {}", domain))?; |
| 243 | |
| 244 | let certified_key = Arc::new(certified_key); |
| 245 | |
| 246 | // Gateway certificates are always wildcard certs |
| 247 | // domain is the base domain (e.g., "example.com"), cert is for "*.example.com" |
| 248 | self.wildcard_certs |
| 249 | .insert(domain.to_string(), certified_key); |
| 250 | info!( |
| 251 | "cert_store: prepared wildcard certificate for *.{} (expires: {})", |
| 252 | domain, |
| 253 | format_expiry(data.not_after) |
| 254 | ); |
| 255 | |
| 256 | // Store metadata |
| 257 | self.cert_data.insert(domain.to_string(), data.clone()); |
| 258 | |
| 259 | Ok(()) |
| 260 | } |
| 261 | |
| 262 | /// Build the immutable CertStore |
| 263 | pub fn build(self) -> CertStore { |