diff options
Diffstat (limited to 'src/cli/credentials.h')
-rw-r--r-- | src/cli/credentials.h | 37 |
1 files changed, 11 insertions, 26 deletions
diff --git a/src/cli/credentials.h b/src/cli/credentials.h index da21dd842..74961a774 100644 --- a/src/cli/credentials.h +++ b/src/cli/credentials.h @@ -13,6 +13,10 @@ #include <botan/data_src.h> #include <memory> +#if defined(BOTAN_HAS_CERTSTOR_SYSTEM) + #include <botan/certstor_system.h> +#endif + inline bool value_exists(const std::vector<std::string>& vec, const std::string& val) { @@ -30,23 +34,19 @@ class Basic_Credentials_Manager : public Botan::Credentials_Manager { public: Basic_Credentials_Manager(bool use_system_store, - const std::string& ca_paths) + const std::string& ca_path) { - std::vector<std::string> paths; - - if(ca_paths.empty() == false) - paths.push_back(ca_paths); - - if(use_system_store) + if(ca_path.empty() == false) { - paths.push_back("/etc/ssl/certs"); - paths.push_back("/usr/share/ca-certificates"); + m_certstores.push_back(std::make_shared<Botan::Certificate_Store_In_Memory>(ca_path)); } - if(paths.empty() == false) +#if defined(BOTAN_HAS_CERTSTOR_SYSTEM) + if(use_system_store) { - load_certstores(paths); + m_certstores.push_back(std::make_shared<Botan::System_Certificate_Store>()); } +#endif } Basic_Credentials_Manager(Botan::RandomNumberGenerator& rng, @@ -74,21 +74,6 @@ class Basic_Credentials_Manager : public Botan::Credentials_Manager m_creds.push_back(cert); } - void load_certstores(const std::vector<std::string>& paths) - { - try - { - for(auto const& path : paths) - { - std::shared_ptr<Botan::Certificate_Store> cs(new Botan::Certificate_Store_In_Memory(path)); - m_certstores.push_back(cs); - } - } - catch(std::exception&) - { - } - } - std::vector<Botan::Certificate_Store*> trusted_certificate_authorities(const std::string& type, const std::string& /*hostname*/) override |