aboutsummaryrefslogtreecommitdiffstats
path: root/src/x509cert.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2006-06-23 06:01:47 +0000
committerlloyd <[email protected]>2006-06-23 06:01:47 +0000
commitedd3efbc92c0563f607274e33294dc9783e3b05d (patch)
tree61085433f2d451b5e0b80e05457f4f20d0b0d5e7 /src/x509cert.cpp
parent940697169376f32d10da71d6f0d4660a71c45545 (diff)
Make create_dn (from x509cert.cpp) a public function. Add a
create_alt_name that performs the same sort of extraction for alternative names.
Diffstat (limited to 'src/x509cert.cpp')
-rw-r--r--src/x509cert.cpp87
1 files changed, 56 insertions, 31 deletions
diff --git a/src/x509cert.cpp b/src/x509cert.cpp
index 817f5a27d..b65fdef5c 100644
--- a/src/x509cert.cpp
+++ b/src/x509cert.cpp
@@ -16,37 +16,6 @@
namespace Botan {
-namespace {
-
-/*************************************************
-* Create and populate a X509_DN *
-*************************************************/
-X509_DN create_dn(const Data_Store& info)
- {
- class DN_Matcher : public Data_Store::Matcher
- {
- public:
- bool operator()(const std::string& key, const std::string&) const
- {
- if(key.find("X520.") != std::string::npos)
- return true;
- return false;
- }
- };
-
- std::multimap<std::string, std::string> names
- = info.search_with(DN_Matcher());
-
- typedef std::multimap<std::string, std::string>::const_iterator rdn_iter;
-
- X509_DN new_dn;
- for(rdn_iter j = names.begin(); j != names.end(); ++j)
- new_dn.add_attribute(j->first, j->second);
- return new_dn;
- }
-
-}
-
/*************************************************
* X509_Certificate Constructor *
*************************************************/
@@ -307,4 +276,60 @@ bool operator!=(const X509_Certificate& cert1, const X509_Certificate& cert2)
return !(cert1 == cert2);
}
+/*************************************************
+* Create and populate a X509_DN *
+*************************************************/
+X509_DN create_dn(const Data_Store& info)
+ {
+ class DN_Matcher : public Data_Store::Matcher
+ {
+ public:
+ bool operator()(const std::string& key, const std::string&) const
+ {
+ if(key.find("X520.") != std::string::npos)
+ return true;
+ return false;
+ }
+ };
+
+ std::multimap<std::string, std::string> names
+ = info.search_with(DN_Matcher());
+
+ X509_DN dn;
+
+ std::multimap<std::string, std::string>::iterator j;
+ for(j = names.begin(); j != names.end(); ++j)
+ dn.add_attribute(j->first, j->second);
+
+ return dn;
+ }
+
+/*************************************************
+* Create and populate an AlternativeName *
+*************************************************/
+AlternativeName create_alt_name(const Data_Store& info)
+ {
+ class AltName_Matcher : public Data_Store::Matcher
+ {
+ public:
+ bool operator()(const std::string& key, const std::string&) const
+ {
+ if(key == "RFC882" || key == "DNS" || key == "URI")
+ return true;
+ return false;
+ }
+ };
+
+ std::multimap<std::string, std::string> names
+ = info.search_with(AltName_Matcher());
+
+ AlternativeName alt_name;
+
+ std::multimap<std::string, std::string>::iterator j;
+ for(j = names.begin(); j != names.end(); ++j)
+ alt_name.add_attribute(j->first, j->second);
+
+ return alt_name;
+ }
+
}