diff options
-rw-r--r-- | src/lib/x509/x509path.cpp | 14 | ||||
-rw-r--r-- | src/lib/x509/x509path.h | 5 | ||||
-rw-r--r-- | src/tests/test_x509_path.cpp | 2 |
3 files changed, 21 insertions, 0 deletions
diff --git a/src/lib/x509/x509path.cpp b/src/lib/x509/x509path.cpp index 842e97fd0..0914348ee 100644 --- a/src/lib/x509/x509path.cpp +++ b/src/lib/x509/x509path.cpp @@ -1043,4 +1043,18 @@ const char* Path_Validation_Result::status_string(Certificate_Status_Code code) return "Unknown error"; } +std::string Path_Validation_Result::warnings_string() const + { + const std::string sep(", "); + std::string res; + for(size_t i = 0; i < m_warnings.size(); i++) + { + for(auto code : m_warnings[i]) + res += "[" + std::to_string(i) + "] " + status_string(code) + sep; + } + // remove last sep + if(res.size() >= sep.size()) + res = res.substr(0, res.size() - sep.size()); + return res; + } } diff --git a/src/lib/x509/x509path.h b/src/lib/x509/x509path.h index 12a924873..65497b2cc 100644 --- a/src/lib/x509/x509path.h +++ b/src/lib/x509/x509path.h @@ -162,6 +162,11 @@ class BOTAN_PUBLIC_API(2,0) Path_Validation_Result final std::string result_string() const; /** + * @return string representation of the warnings + */ + std::string warnings_string() const; + + /** * @param code validation status code * @return corresponding validation status message */ diff --git a/src/tests/test_x509_path.cpp b/src/tests/test_x509_path.cpp index 3e45f6072..7a9ff97bc 100644 --- a/src/tests/test_x509_path.cpp +++ b/src/tests/test_x509_path.cpp @@ -112,6 +112,8 @@ class X509test_Path_Validation_Tests final : public Test } result.test_eq("test " + filename, path_result.result_string(), expected_result); + result.test_eq("test no warnings string", path_result.warnings_string(), ""); + result.confirm("test no warnings", path_result.no_warnings() == true); result.end_timer(); results.push_back(result); } |