aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorTim Oesterreich <[email protected]>2019-05-07 11:20:40 +0200
committerTim Oesterreich <[email protected]>2019-05-07 11:20:40 +0200
commit7ab1a0559d17790fad746427390d4bb40207ad93 (patch)
treea77ac3be75303066dab2026a547c44c7d7cbcfde /src/lib
parentab6faeaf43b5515fa9136bfdb8501a1e97bf7133 (diff)
use map of vectors instead of multimap in flatfile certstor
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/x509/certstor_flatfile/certstor_flatfile.cpp25
-rw-r--r--src/lib/x509/certstor_flatfile/certstor_flatfile.h2
2 files changed, 13 insertions, 14 deletions
diff --git a/src/lib/x509/certstor_flatfile/certstor_flatfile.cpp b/src/lib/x509/certstor_flatfile/certstor_flatfile.cpp
index 24cea1d40..90feecd24 100644
--- a/src/lib/x509/certstor_flatfile/certstor_flatfile.cpp
+++ b/src/lib/x509/certstor_flatfile/certstor_flatfile.cpp
@@ -60,7 +60,7 @@ Flatfile_Certificate_Store::Flatfile_Certificate_Store(const std::string& file,
if(cert->is_self_signed() && cert->is_CA_cert())
{
m_all_subjects.push_back(cert->subject_dn());
- m_dn_to_cert.emplace(cert->subject_dn(), cert);
+ m_dn_to_cert[cert->subject_dn()].push_back(cert);
m_pubkey_sha1_to_cert.emplace(cert->subject_public_key_bitstring_sha1(), cert);
m_subject_dn_sha256_to_cert.emplace(cert->raw_subject_dn_sha256(), cert);
}
@@ -94,24 +94,23 @@ std::vector<std::shared_ptr<const X509_Certificate>> Flatfile_Certificate_Store:
const X509_DN& subject_dn,
const std::vector<uint8_t>& key_id) const
{
- const auto found_range = m_dn_to_cert.equal_range(subject_dn);
-
- if(found_range.first == m_dn_to_cert.end())
- {
- return {};
- }
-
std::vector<std::shared_ptr<const X509_Certificate>> found_certs;
-
- for(auto i = found_range.first; i != found_range.second; ++i)
+ try
{
- const std::shared_ptr<const X509_Certificate> cert = i->second;
+ const auto certs = m_dn_to_cert.at(subject_dn);
- if(key_id.empty() || key_id == cert->subject_key_id())
+ for(auto cert : certs)
{
- found_certs.push_back(cert);
+ if(key_id.empty() || key_id == cert->subject_key_id())
+ {
+ found_certs.push_back(cert);
+ }
}
}
+ catch(const std::out_of_range&)
+ {
+ return {};
+ }
return found_certs;
}
diff --git a/src/lib/x509/certstor_flatfile/certstor_flatfile.h b/src/lib/x509/certstor_flatfile/certstor_flatfile.h
index a778e045e..9c0949bcd 100644
--- a/src/lib/x509/certstor_flatfile/certstor_flatfile.h
+++ b/src/lib/x509/certstor_flatfile/certstor_flatfile.h
@@ -76,7 +76,7 @@ class BOTAN_PUBLIC_API(2, 11) Flatfile_Certificate_Store final : public Certific
private:
std::vector<X509_DN> m_all_subjects;
- std::multimap<X509_DN, std::shared_ptr<const X509_Certificate>> m_dn_to_cert;
+ std::map<X509_DN, std::vector<std::shared_ptr<const X509_Certificate>>> m_dn_to_cert;
std::map<std::vector<uint8_t>, std::shared_ptr<const X509_Certificate>> m_pubkey_sha1_to_cert;
std::map<std::vector<uint8_t>, std::shared_ptr<const X509_Certificate>> m_subject_dn_sha256_to_cert;
};