aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2016-11-26 20:22:02 -0500
committerJack Lloyd <[email protected]>2016-11-26 20:22:02 -0500
commit5c41db5f0ca5c755215663102569f3ab38dccc54 (patch)
tree7a7e5b59e7ed77a32a8af525db30f5576e17a4be
parentdb6cc169d2a62b6ba9ccf881f9eb2e7c5e28692a (diff)
Add TLS::Policy::to_string
-rw-r--r--src/lib/tls/tls_policy.cpp7
-rw-r--r--src/lib/tls/tls_policy.h6
2 files changed, 13 insertions, 0 deletions
diff --git a/src/lib/tls/tls_policy.cpp b/src/lib/tls/tls_policy.cpp
index 4bd071d0b..e9caa8bb3 100644
--- a/src/lib/tls/tls_policy.cpp
+++ b/src/lib/tls/tls_policy.cpp
@@ -474,6 +474,13 @@ void Policy::print(std::ostream& o) const
o << "minimum_signature_strength = " << minimum_signature_strength() << '\n';
}
+std::string Policy::to_string() const
+ {
+ std::ostringstream oss;
+ this->print(oss);
+ return oss.str();
+ }
+
std::vector<std::string> Strict_Policy::allowed_ciphers() const
{
return { "ChaCha20Poly1305", "AES-256/GCM", "AES-128/GCM" };
diff --git a/src/lib/tls/tls_policy.h b/src/lib/tls/tls_policy.h
index 519139fff..f992949fe 100644
--- a/src/lib/tls/tls_policy.h
+++ b/src/lib/tls/tls_policy.h
@@ -284,6 +284,12 @@ class BOTAN_DLL Policy
*/
virtual void print(std::ostream& o) const;
+ /**
+ * Convert this policy to a printable format.
+ * Same as calling `print` on a ostringstream and reading o.str()
+ */
+ std::string to_string() const;
+
virtual ~Policy() {}
};