aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/utils/parsing.cpp
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2015-10-23 15:32:15 -0400
committerJack Lloyd <[email protected]>2015-10-23 15:32:15 -0400
commit3e44cbed78eb528daa38f9837d67aa0471ee7bd2 (patch)
tree01539aa0dd511db79e6d218394ea3fd51db94756 /src/lib/utils/parsing.cpp
parent69a5a56b38a309241126641149471a36137507a0 (diff)
Fix cert validation bugs found by x509test.
Add test suite with certs from x509test
Diffstat (limited to 'src/lib/utils/parsing.cpp')
-rw-r--r--src/lib/utils/parsing.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/lib/utils/parsing.cpp b/src/lib/utils/parsing.cpp
index ea89c8e5f..40eae656a 100644
--- a/src/lib/utils/parsing.cpp
+++ b/src/lib/utils/parsing.cpp
@@ -1,6 +1,6 @@
/*
* Various string utils and parsing functions
-* (C) 1999-2007,2013,2014 Jack Lloyd
+* (C) 1999-2007,2013,2014,2015 Jack Lloyd
* (C) 2015 Simon Warta (Kullo GmbH)
*
* Botan is released under the Simplified BSD License (see license.txt)
@@ -333,4 +333,25 @@ std::string replace_char(const std::string& str, char from_char, char to_char)
return out;
}
+bool host_wildcard_match(const std::string& issued, const std::string& host)
+ {
+ if(issued == host)
+ return true;
+
+ if(issued.size() > 2 && issued[0] == '*' && issued[1] == '.')
+ {
+ size_t host_i = host.find('.');
+ if(host_i == std::string::npos || host_i == host.size() - 1)
+ return false;
+
+ const std::string host_base = host.substr(host_i + 1);
+ const std::string issued_base = issued.substr(2);
+
+ if(host_base == issued_base)
+ return true;
+ }
+
+ return false;
+ }
+
}