From fa9c1ecb2c8abb0afe3f41666607bdf39f47c60f Mon Sep 17 00:00:00 2001 From: Dmitry Date: Tue, 22 Oct 2024 14:18:55 +0300 Subject: [PATCH] + san email --- src/crypto.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/crypto.rs b/src/crypto.rs index 380dd68..3f92228 100644 --- a/src/crypto.rs +++ b/src/crypto.rs @@ -343,9 +343,16 @@ impl ICryptoProvider for OpenSSLLibProvider { csr_builder.set_version(2).context("set version")?; let context = csr_builder.x509v3_context(Some(&conf)); + let mut san_extension = SubjectAlternativeName::new(); - san_extension.dns(self.vars.get("KEY_NAME").unwrap()); + if let Some(name) = self.vars.get("KEY_NAME") { + san_extension.dns(name); + } + if let Some(email) = self.vars.get("KEY_EMAIL") { + san_extension.email(email); + } let san_ext = san_extension.build(&context).context("build san")?; + st.push(san_ext).context("push san")?; csr_builder @@ -416,9 +423,16 @@ impl ICryptoProvider for OpenSSLLibProvider { .context("set_subject_name")?; let context = builder.x509v3_context(Some(&ca_cert), None); + let mut san_extension = SubjectAlternativeName::new(); - san_extension.dns(self.vars.get("KEY_NAME").unwrap()); + if let Some(name) = self.vars.get("KEY_NAME") { + san_extension.dns(name); + } + if let Some(email) = self.vars.get("KEY_EMAIL") { + san_extension.email(email); + } let san_ext = san_extension.build(&context).context("build san")?; + builder .append_extension(san_ext) .context("append san ext")?;