summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGalen Guyer <galen@galenguyer.com>2022-06-20 21:40:40 -0400
committerGalen Guyer <galen@galenguyer.com>2022-06-20 21:43:12 -0400
commita850fd3ebd41bf6f7591ee5512bfb1c0808f0e0b (patch)
treeb6403ef40224fe313c17cad472450e983af86988
parent5df81c937fbf71d7d81aa19a0c3820aa3d2f436e (diff)
set SANs correctly for single CN
-rw-r--r--Cargo.lock2
-rw-r--r--Cargo.toml2
-rw-r--r--src/lib/mod.rs2
-rw-r--r--src/lib/req.rs8
4 files changed, 11 insertions, 3 deletions
diff --git a/Cargo.lock b/Cargo.lock
index a2df4a1..c64492e 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -117,7 +117,7 @@ dependencies = [
[[package]]
name = "hancock"
-version = "1.0.0"
+version = "1.1.0"
dependencies = [
"clap",
"openssl",
diff --git a/Cargo.toml b/Cargo.toml
index ff041c4..8679984 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "hancock"
-version = "1.0.0"
+version = "1.1.0"
edition = "2021"
diff --git a/src/lib/mod.rs b/src/lib/mod.rs
index 654585a..56a7b42 100644
--- a/src/lib/mod.rs
+++ b/src/lib/mod.rs
@@ -1,9 +1,9 @@
pub mod cert;
+pub mod ops;
pub mod path;
pub mod pkey;
pub mod req;
pub mod root;
-pub mod ops;
#[derive(Clone, Copy)]
pub enum KeyType {
diff --git a/src/lib/req.rs b/src/lib/req.rs
index 2b5974f..3e6a311 100644
--- a/src/lib/req.rs
+++ b/src/lib/req.rs
@@ -73,6 +73,14 @@ pub fn generate_req(
}
}
}
+
+ if let Some(cn) = common_name {
+ if IpAddr::from_str(cn).is_ok() {
+ subject_alt_name.ip(cn);
+ } else {
+ subject_alt_name.dns(cn);
+ }
+ }
let subject_alt_name = subject_alt_name
.build(&x509req_builder.x509v3_context(None))
.unwrap();