diff options
author | Jack Lloyd <[email protected]> | 2018-03-24 05:42:20 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-03-24 05:42:20 -0400 |
commit | 04729be983f3090595f92c2d4752081487ea7c4d (patch) | |
tree | 3b20d85a3fbaf0d520b78839ad64b328fc9dc162 /src/cli/credentials.h | |
parent | 8cbcc468ee8a1767f091b7aa73ab3a3b08bde253 (diff) |
Add some options to tls_client cli to control trusted CAs
Diffstat (limited to 'src/cli/credentials.h')
-rw-r--r-- | src/cli/credentials.h | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/cli/credentials.h b/src/cli/credentials.h index 3b46c239c..da21dd842 100644 --- a/src/cli/credentials.h +++ b/src/cli/credentials.h @@ -29,9 +29,24 @@ inline bool value_exists(const std::vector<std::string>& vec, class Basic_Credentials_Manager : public Botan::Credentials_Manager { public: - Basic_Credentials_Manager() + Basic_Credentials_Manager(bool use_system_store, + const std::string& ca_paths) { - load_certstores(); + std::vector<std::string> paths; + + if(ca_paths.empty() == false) + paths.push_back(ca_paths); + + if(use_system_store) + { + paths.push_back("/etc/ssl/certs"); + paths.push_back("/usr/share/ca-certificates"); + } + + if(paths.empty() == false) + { + load_certstores(paths); + } } Basic_Credentials_Manager(Botan::RandomNumberGenerator& rng, @@ -59,13 +74,10 @@ class Basic_Credentials_Manager : public Botan::Credentials_Manager m_creds.push_back(cert); } - void load_certstores() + void load_certstores(const std::vector<std::string>& paths) { try { - // TODO: make path configurable - const std::vector<std::string> paths = { "/etc/ssl/certs", "/usr/share/ca-certificates" }; - for(auto const& path : paths) { std::shared_ptr<Botan::Certificate_Store> cs(new Botan::Certificate_Store_In_Memory(path)); |