diff options
Diffstat (limited to 'doc/examples')
-rw-r--r-- | doc/examples/tls_client.cpp | 18 | ||||
-rw-r--r-- | doc/examples/tls_server.cpp | 17 |
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) { |