diff options
author | lloyd <[email protected]> | 2011-04-04 03:43:52 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2011-04-04 03:43:52 +0000 |
commit | 3b9bfbd07c3723662832caf5b1efe04de28b656d (patch) | |
tree | ee2a9324f384efead6e5bb87ac8374e7e8734c90 /doc/examples/tls_client.cpp | |
parent | 04db054f1ae8de572ee9c0cfe227e76f84096bd6 (diff) |
Convert most of the documentation to reStructured Text, adding
a makefile to build it with Sphinx (http://sphinx.pocoo.org/).
Previously credits.txt listed public domain code sources; instead
directly credit the authors in the relevant files and delete that
file.
Drop the draft FIPS 140 security policy; I can't imagine FIPS 140
validation will ever happen, and if it does, I don't want
anything to do with it.
Also drop the internals doc, which was so out of date (and
incomplete) as to be worthless.
Move the tutorials and InSiTo pdfs into old/ for the time being,
until anything relevant from them can be filtered out and
converted into RST.
Diffstat (limited to 'doc/examples/tls_client.cpp')
-rw-r--r-- | doc/examples/tls_client.cpp | 96 |
1 files changed, 0 insertions, 96 deletions
diff --git a/doc/examples/tls_client.cpp b/doc/examples/tls_client.cpp deleted file mode 100644 index 10ead20cc..000000000 --- a/doc/examples/tls_client.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* -* (C) 2008 Jack Lloyd -* -* Distributed under the terms of the Botan license -*/ - -#include <botan/init.h> -#include <botan/tls_client.h> -#include <botan/unx_sock.h> - -using namespace Botan; - -#include <stdio.h> -#include <string> -#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) - { - printf("Usage: %s host [port]\n", argv[0]); - return 1; - } - - try - { - LibraryInitializer init; - - std::string host = argv[1]; - u32bit port = argc == 3 ? Botan::to_u32bit(argv[2]) : 443; - - printf("Connecting to %s:%d...\n", host.c_str(), port); - - Unix_Socket sock(argv[1], port); - - std::auto_ptr<Botan::RandomNumberGenerator> rng( - Botan::RandomNumberGenerator::make_rng()); - - 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), - policy, *rng); - - printf("Handshake extablished...\n"); - -#if 0 - std::string http_command = "GET / HTTP/1.1\r\n" - "Server: " + host + ':' + to_string(port) + "\r\n\r\n"; -#else - std::string http_command = "GET / HTTP/1.0\r\n\r\n"; -#endif - - tls.write((const byte*)http_command.c_str(), http_command.length()); - - u32bit total_got = 0; - - while(true) - { - if(tls.is_closed()) - break; - - byte buf[16+1] = { 0 }; - u32bit got = tls.read(buf, sizeof(buf)-1); - printf("%s", buf); - fflush(0); - - total_got += got; - } - - printf("\nRetrieved %d bytes total\n", total_got); - } - catch(std::exception& e) - { - printf("%s\n", e.what()); - return 1; - } - return 0; - } |