aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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() {}
};