Browse Source

Use the native openssl methods for SAN construction

The openssl crate does support having multiple DNS entries in the SAN
extension, there is no need to re-implement it.
pull/5/head
Rodolphe Breard 6 years ago
parent
commit
b8aa782dd2
  1. 7
      acmed/src/acme_proto/certificate.rs

7
acmed/src/acme_proto/certificate.rs

@ -42,11 +42,14 @@ pub fn generate_csr(
priv_key: &PKey<Private>, priv_key: &PKey<Private>,
pub_key: &PKey<Public>, pub_key: &PKey<Public>,
) -> Result<String, Error> { ) -> Result<String, Error> {
let domains = cert.domains.join(", DNS:");
let mut builder = X509ReqBuilder::new()?; let mut builder = X509ReqBuilder::new()?;
builder.set_pubkey(pub_key)?; builder.set_pubkey(pub_key)?;
let ctx = builder.x509v3_context(None); let ctx = builder.x509v3_context(None);
let san = SubjectAlternativeName::new().dns(&domains).build(&ctx)?;
let mut san = SubjectAlternativeName::new();
for name in cert.domains.iter() {
san.dns(&name);
}
let san = san.build(&ctx)?;
let mut ext_stack = Stack::new()?; let mut ext_stack = Stack::new()?;
ext_stack.push(san)?; ext_stack.push(san)?;
builder.add_extensions(&ext_stack)?; builder.add_extensions(&ext_stack)?;

Loading…
Cancel
Save