aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-11-29 15:30:35 +0000
committerlloyd <[email protected]>2010-11-29 15:30:35 +0000
commit3d87cc7f75b1d308e3411b8c3df81f40b9ab4d1a (patch)
treeaa47d583a71e88c3613225a9b5723c19ee9308a1
parent01bbd9f35711a059e9f90e1a79bf8d0e862c9950 (diff)
Inherit policy and override check_cert
-rw-r--r--doc/examples/tls_client.cpp18
-rw-r--r--doc/examples/tls_server.cpp17
2 files changed, 33 insertions, 2 deletions
diff --git a/doc/examples/tls_client.cpp b/doc/examples/tls_client.cpp
index 854cb3b28..10ead20cc 100644
--- a/doc/examples/tls_client.cpp
+++ b/doc/examples/tls_client.cpp
@@ -15,6 +15,22 @@ using namespace Botan;
#include <iostream>
#include <memory>
+class Client_TLS_Policy : public TLS_Policy
+ {
+ public:
+ bool check_cert(const std::vector<X509_Certificate>& certs) const
+ {
+ for(size_t i = 0; i != certs.size(); ++i)
+ {
+ std::cout << certs[i].to_string();
+ }
+
+ std::cout << "Warning: not checking cert signatures\n";
+
+ return true;
+ }
+ };
+
int main(int argc, char* argv[])
{
if(argc != 2 && argc != 3)
@@ -37,7 +53,7 @@ int main(int argc, char* argv[])
std::auto_ptr<Botan::RandomNumberGenerator> rng(
Botan::RandomNumberGenerator::make_rng());
- TLS_Policy policy;
+ Client_TLS_Policy policy;
TLS_Client tls(std::tr1::bind(&Socket::read, std::tr1::ref(sock), _1, _2),
std::tr1::bind(&Socket::write, std::tr1::ref(sock), _1, _2),
diff --git a/doc/examples/tls_server.cpp b/doc/examples/tls_server.cpp
index e45a24759..91bb9ffbf 100644
--- a/doc/examples/tls_server.cpp
+++ b/doc/examples/tls_server.cpp
@@ -19,6 +19,21 @@ using namespace Botan;
#include <iostream>
#include <memory>
+class Server_TLS_Policy : public TLS_Policy
+ {
+ public:
+ bool check_cert(const std::vector<X509_Certificate>& certs) const
+ {
+ for(size_t i = 0; i != certs.size(); ++i)
+ {
+ std::cout << certs[i].to_string();
+ }
+
+ std::cout << "Warning: not checking cert signatures\n";
+
+ return true;
+ }
+ };
int main(int argc, char* argv[])
{
@@ -44,7 +59,7 @@ int main(int argc, char* argv[])
Unix_Server_Socket listener(port);
- TLS_Policy policy;
+ Server_TLS_Policy policy;
while(true)
{