| 582 | } |
| 583 | |
| 584 | fn extract_subject_alt_names(cert_pem: &str) -> Result<Vec<String>> { |
| 585 | let pem = read_pem(cert_pem)?; |
| 586 | let cert = pem.parse_x509().context("Invalid x509 certificate")?; |
| 587 | let subject_alt_names = cert |
| 588 | .tbs_certificate |
| 589 | .subject_alternative_name() |
| 590 | .context("failed to parse subject alternative name")? |
| 591 | .context("no subject alternative name found")?; |
| 592 | let mut domains = Vec::new(); |
| 593 | for name in &subject_alt_names.value.general_names { |
| 594 | if let GeneralName::DNSName(dns) = name { |
| 595 | domains.push(dns.to_string()); |
| 596 | } else { |
| 597 | bail!("unsupported general name: {:?}", name); |
| 598 | } |
| 599 | } |
| 600 | Ok(domains) |
| 601 | } |
| 602 | |
| 603 | fn ln_force(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> Result<()> { |
| 604 | // Check if the symlink exists without following it |