diff options
author | lloyd <[email protected]> | 2010-09-08 11:44:36 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-09-08 11:44:36 +0000 |
commit | d0664d00160896f3456e34e4107396e63241e749 (patch) | |
tree | 114ad2d674e975d1f03c9abb09d35b6144be475b /doc/examples/tls_client.cpp | |
parent | 21109ed6afbce006903b7ebc1d3e6befaa136de5 (diff) |
Specify the target host and port for tls_client on the command line
Diffstat (limited to 'doc/examples/tls_client.cpp')
-rw-r--r-- | doc/examples/tls_client.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/doc/examples/tls_client.cpp b/doc/examples/tls_client.cpp index 5006e0a1a..9e9fce9c2 100644 --- a/doc/examples/tls_client.cpp +++ b/doc/examples/tls_client.cpp @@ -15,20 +15,35 @@ using namespace Botan; #include <iostream> #include <memory> -int main() +int main(int argc, char* argv[]) { + if(argc != 2 && argc != 3) + { + printf("Usage: %s host [port]\n", argv[0]); + return 1; + } + try { LibraryInitializer init; - Unix_Socket sock("www.randombit.net", 443); + 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()); TLS_Client tls(*rng, sock); - std::string http_command = "GET /bitbashing\r\n"; + printf("Handshake extablished...\n"); + + std::string http_command = "GET / HTTP/1.1\r\n" + "Server: " + host + ':' + to_string(port) + "\r\n\r\n"; + tls.write((const byte*)http_command.c_str(), http_command.length()); u32bit total_got = 0; |