diff options
| author | Carl Hetherington <cth@carlh.net> | 2022-02-14 10:36:07 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2022-02-14 10:36:07 +0100 |
| commit | c5a9590a9a84eb4eee8536dfa1eef59d7126eeac (patch) | |
| tree | 5e70dbe93e9c3b35a8bf00faba8f1ec856e9e8d6 | |
| parent | f258388fd0a521f3d58a91e78c4460784f6700f3 (diff) | |
Extract check_certificates() method.
| -rw-r--r-- | src/lib/config.cc | 46 | ||||
| -rw-r--r-- | src/lib/config.h | 2 |
2 files changed, 29 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; +} + diff --git a/src/lib/config.h b/src/lib/config.h index be4e6ecf1..e01eab780 100644 --- a/src/lib/config.h +++ b/src/lib/config.h @@ -1084,6 +1084,8 @@ public: void rename_template (std::string old_name, std::string new_name) const; void delete_template (std::string name) const; + boost::optional<BadReason> check_certificates () const; + static Config* instance (); static void drop (); static void restore_defaults (); |
