Skip to content

Commit d542b04

Browse files
committed
[#3255] Added a getTlsContext to HTTP listener
1 parent a7bb3fb commit d542b04

File tree

5 files changed

+17
-0
lines changed

5 files changed

+17
-0
lines changed

src/lib/http/listener.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ HttpListener::getLocalPort() const {
4242
return (impl_->getEndpoint().getPort());
4343
}
4444

45+
const TlsContextPtr&
46+
HttpListener::getTlsContext() const {
47+
return (impl_->getTlsContext());
48+
}
49+
4550
int
4651
HttpListener::getNative() const {
4752
return (impl_->getNative());

src/lib/http/listener.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ class HttpListener {
115115
/// @brief Returns local port on which server is listening.
116116
uint16_t getLocalPort() const;
117117

118+
/// @brief Returns reference to the current TLS context.
119+
const asiolink::TlsContextPtr& getTlsContext() const;
120+
118121
/// @brief file descriptor of the underlying acceptor socket.
119122
int getNative() const;
120123

src/lib/http/listener_impl.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ HttpListenerImpl::getEndpoint() const {
7070
return (*endpoint_);
7171
}
7272

73+
const TlsContextPtr&
74+
HttpListenerImpl::getTlsContext() const {
75+
return (tls_context_);
76+
}
77+
7378
int
7479
HttpListenerImpl::getNative() const {
7580
return (acceptor_ ? acceptor_->getNative() : -1);

src/lib/http/listener_impl.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ class HttpListenerImpl : public boost::enable_shared_from_this<HttpListenerImpl>
6060
/// @brief Returns reference to the current listener endpoint.
6161
const asiolink::TCPEndpoint& getEndpoint() const;
6262

63+
/// @brief Returns reference to the current TLS context.
64+
const asiolink::TlsContextPtr& getTlsContext() const;
65+
6366
/// @brief file descriptor of the underlying acceptor socket.
6467
int getNative() const;
6568

src/lib/http/tests/http_server_test.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ class BaseListenerTest : public ::testing::Test {
392392
ASSERT_NO_THROW(listener.start());
393393
ASSERT_EQ(SERVER_ADDRESS, listener.getLocalAddress().toText());
394394
ASSERT_EQ(SERVER_PORT, listener.getLocalPort());
395+
ASSERT_EQ(server_context_, listener.getTlsContext());
395396
ASSERT_NO_THROW(startRequest(request));
396397
ASSERT_NO_THROW(runIOService());
397398
ASSERT_EQ(1, clients_.size());

0 commit comments

Comments
 (0)