aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlloyd <[email protected]>2012-06-20 15:54:42 +0000
committerlloyd <[email protected]>2012-06-20 15:54:42 +0000
commit38acefedb83e291d13431a85120c942a389e0b99 (patch)
tree09acf27d0b4cadba0842bfbff8cba263335cc277
parentd7fca253446491f0fa3985cba73fed08af9283ef (diff)
Return existing certs fast if there is a match
-rw-r--r--doc/examples/credentials.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/doc/examples/credentials.h b/doc/examples/credentials.h
index 9e3ca741a..2aeb3ab65 100644
--- a/doc/examples/credentials.h
+++ b/doc/examples/credentials.h
@@ -237,6 +237,20 @@ class Credentials_Manager_Simple : public Botan::Credentials_Manager
if(hostname == "nosuchname")
return std::vector<Botan::X509_Certificate>();
+ for(auto i : certs_and_keys)
+ {
+ if(hostname != "" && !i.first.matches_dns_name(hostname))
+ continue;
+
+ if(!value_exists(cert_key_types, i.second->algo_name()))
+ continue;
+
+ certs.push_back(i.first);
+ }
+
+ if(!certs.empty())
+ return certs;
+
std::string key_name = "";
if(value_exists(cert_key_types, "RSA"))
@@ -280,6 +294,7 @@ class Credentials_Manager_Simple : public Botan::Credentials_Manager
Botan::RandomNumberGenerator& rng;
Botan::SymmetricKey session_ticket_key;
+
std::map<Botan::X509_Certificate, Botan::Private_Key*> certs_and_keys;
};