summaryrefslogtreecommitdiff
path: root/src/certificate_chain.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2022-02-12 15:55:47 +0100
committerCarl Hetherington <cth@carlh.net>2022-02-12 15:55:47 +0100
commit4b48bfa7f069092e53bc7fcba93a99d34b18be8a (patch)
tree77c7c30dea3974e28f75bfccdd077efa85487c90 /src/certificate_chain.cc
parent575129cca8f3161881fab63bf2961d102c24c286 (diff)
Make certificate chain validity a parameter of the constructor.v1.6.19
Diffstat (limited to 'src/certificate_chain.cc')
-rw-r--r--src/certificate_chain.cc14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/certificate_chain.cc b/src/certificate_chain.cc
index 92e3aca1..7ade2e8c 100644
--- a/src/certificate_chain.cc
+++ b/src/certificate_chain.cc
@@ -179,6 +179,7 @@ public_key_digest (boost::filesystem::path private_key, boost::filesystem::path
CertificateChain::CertificateChain (
boost::filesystem::path openssl,
+ int validity_in_days,
string organisation,
string organisational_unit,
string root_common_name,
@@ -186,9 +187,6 @@ CertificateChain::CertificateChain (
string leaf_common_name
)
{
- /* Valid for 40 years */
- int const days = 365 * 40;
-
boost::filesystem::path directory = boost::filesystem::temp_directory_path() / boost::filesystem::unique_path ();
boost::filesystem::create_directories (directory);
@@ -226,7 +224,7 @@ CertificateChain::CertificateChain (
String::compose (
"%1 req -new -x509 -sha256 -config ca.cnf -days %2 -set_serial 5"
" -subj \"%3\" -key ca.key -outform PEM -out ca.self-signed.pem",
- quoted_openssl, days, ca_subject
+ quoted_openssl, validity_in_days, ca_subject
)
);
}
@@ -259,7 +257,7 @@ CertificateChain::CertificateChain (
command (
String::compose (
"%1 req -new -config intermediate.cnf -days %2 -subj \"%3\" -key intermediate.key -out intermediate.csr",
- quoted_openssl, days - 1, inter_subject
+ quoted_openssl, validity_in_days - 1, inter_subject
)
);
}
@@ -268,7 +266,7 @@ CertificateChain::CertificateChain (
String::compose(
"%1 x509 -req -sha256 -days %2 -CA ca.self-signed.pem -CAkey ca.key -set_serial 6"
" -in intermediate.csr -extfile intermediate.cnf -extensions v3_ca -out intermediate.signed.pem",
- quoted_openssl, days - 1
+ quoted_openssl, validity_in_days - 1
)
);
@@ -300,7 +298,7 @@ CertificateChain::CertificateChain (
command (
String::compose (
"%1 req -new -config leaf.cnf -days %2 -subj \"%3\" -key leaf.key -outform PEM -out leaf.csr",
- quoted_openssl, days - 2, leaf_subject
+ quoted_openssl, validity_in_days - 2, leaf_subject
)
);
}
@@ -309,7 +307,7 @@ CertificateChain::CertificateChain (
String::compose(
"%1 x509 -req -sha256 -days %2 -CA intermediate.signed.pem -CAkey intermediate.key"
" -set_serial 7 -in leaf.csr -extfile leaf.cnf -extensions v3_ca -out leaf.signed.pem",
- quoted_openssl, days - 2
+ quoted_openssl, validity_in_days - 2
)
);