summaryrefslogtreecommitdiff
path: root/src/lib/config.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2022-02-14 11:00:52 +0100
committerCarl Hetherington <cth@carlh.net>2022-02-14 11:00:52 +0100
commitbdf29b6d0a2cdb392a9d4fd1c214ff108ec84c90 (patch)
tree0b33525bedfe4b393b8d6f3973315e884aa7bb64 /src/lib/config.cc
parent8b1736a39f256b37f75bdb99e69298992d3e1083 (diff)
parent723779c27ffdafe27b3f23840eea4777ae838a83 (diff)
Add a hint about certificate validity, moving some things around
so that it's easier for the user to re-make the certificates if they need to.
Diffstat (limited to 'src/lib/config.cc')
-rw-r--r--src/lib/config.cc46
1 files changed, 27 insertions, 19 deletions
diff --git a/src/lib/config.cc b/src/lib/config.cc
index 371682966..bab15ecb7 100644
--- a/src/lib/config.cc
+++ b/src/lib/config.cc
@@ -450,25 +450,7 @@ try
}
}
- optional<BadReason> bad;
-
- for (auto const& i: _signer_chain->unordered()) {
- if (i.has_utf8_strings()) {
- bad = BAD_SIGNER_UTF8_STRINGS;
- }
- if ((i.not_after().year() - i.not_before().year()) > 15) {
- bad = BAD_SIGNER_VALIDITY_TOO_LONG;
- }
- }
-
- if (!_signer_chain->chain_valid() || !_signer_chain->private_key_valid()) {
- bad = BAD_SIGNER_INCONSISTENT;
- }
-
- if (!_decryption_chain->chain_valid() || !_decryption_chain->private_key_valid()) {
- bad = BAD_DECRYPTION_INCONSISTENT;
- }
-
+ auto bad = check_certificates ();
if (bad) {
auto const remake = Bad(*bad);
if (remake && *remake) {
@@ -1470,3 +1452,29 @@ Config::add_custom_language (dcp::LanguageTag tag)
}
}
+
+optional<Config::BadReason>
+Config::check_certificates () const
+{
+ optional<BadReason> bad;
+
+ for (auto const& i: _signer_chain->unordered()) {
+ if (i.has_utf8_strings()) {
+ bad = BAD_SIGNER_UTF8_STRINGS;
+ }
+ if ((i.not_after().year() - i.not_before().year()) > 15) {
+ bad = BAD_SIGNER_VALIDITY_TOO_LONG;
+ }
+ }
+
+ if (!_signer_chain->chain_valid() || !_signer_chain->private_key_valid()) {
+ bad = BAD_SIGNER_INCONSISTENT;
+ }
+
+ if (!_decryption_chain->chain_valid() || !_decryption_chain->private_key_valid()) {
+ bad = BAD_DECRYPTION_INCONSISTENT;
+ }
+
+ return bad;
+}
+