aboutsummaryrefslogtreecommitdiffstats
path: root/doc/examples/asio_tls_server.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2012-01-26 21:11:52 +0000
committerlloyd <[email protected]>2012-01-26 21:11:52 +0000
commitcb8c64be095a0ef75beb621e8d669096efd7b8ae (patch)
tree5b1c20935afb94f6b02c238295c19373ac8f0e52 /doc/examples/asio_tls_server.cpp
parent4b8786ad157e38b4143b0968c1ea1c83c2ee7388 (diff)
Change callback interface to pass the Alert object itself instead
of just the type code. Implement Alert::type_string
Diffstat (limited to 'doc/examples/asio_tls_server.cpp')
-rw-r--r--doc/examples/asio_tls_server.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/doc/examples/asio_tls_server.cpp b/doc/examples/asio_tls_server.cpp
index 6d6c0e80e..58f59d968 100644
--- a/doc/examples/asio_tls_server.cpp
+++ b/doc/examples/asio_tls_server.cpp
@@ -84,7 +84,7 @@ class tls_server_session : public boost::enable_shared_from_this<tls_server_sess
}
catch(std::exception& e)
{
- printf("Failed - %s\n", e.what());
+ std::cout << "Read failed " << e.what() << "\n";
stop();
return;
}
@@ -98,7 +98,6 @@ class tls_server_session : public boost::enable_shared_from_this<tls_server_sess
else
{
stop();
- //printf("Error in read: %s\n", error.message().c_str());
}
}
@@ -114,7 +113,6 @@ class tls_server_session : public boost::enable_shared_from_this<tls_server_sess
}
else
{
- //printf("Error in write: %s\n", error.message().c_str());
stop();
}
}
@@ -139,12 +137,11 @@ class tls_server_session : public boost::enable_shared_from_this<tls_server_sess
}
}
- void tls_data_recv(const byte buf[], size_t buf_len, Botan::u16bit alert_info)
+ void tls_data_recv(const byte buf[], size_t buf_len, Botan::TLS::Alert alert)
{
- if(buf_len == 0 && alert_info != Botan::TLS::NULL_ALERT)
+ if(alert.is_valid())
{
- //printf("Alert: %d\n", alert_info);
- if(alert_info == 0)
+ if(alert.type() == Botan::TLS::Alert::CLOSE_NOTIFY)
{
m_tls.close();
return;
@@ -157,7 +154,8 @@ class tls_server_session : public boost::enable_shared_from_this<tls_server_sess
out += "\r\n";
out += "HTTP/1.0 200 OK\r\n";
out += "Server: Botan ASIO test server\r\n";
- out += "Host: 192.168.10.5\r\n";
+ if(m_hostname != "")
+ out += "Host: " + m_hostname + "\r\n";
out += "Content-Type: text/html\r\n";
out += "\r\n";
out += "<html><body>Greets. You said: ";
@@ -172,6 +170,7 @@ class tls_server_session : public boost::enable_shared_from_this<tls_server_sess
bool tls_handshake_complete(const Botan::TLS::Session& session)
{
+ m_hostname = session.sni_hostname();
return true;
}
@@ -179,6 +178,7 @@ class tls_server_session : public boost::enable_shared_from_this<tls_server_sess
tcp::socket m_socket;
Botan::TLS::Server m_tls;
+ std::string m_hostname;
unsigned char m_read_buf[Botan::TLS::MAX_TLS_RECORD_SIZE];