]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3255] Added a getTlsContext to HTTP listener
authorFrancis Dupont <fdupont@isc.org>
Fri, 29 Nov 2024 09:36:54 +0000 (10:36 +0100)
committerFrancis Dupont <fdupont@isc.org>
Fri, 29 Nov 2024 09:36:54 +0000 (10:36 +0100)
src/lib/http/listener.cc
src/lib/http/listener.h
src/lib/http/listener_impl.cc
src/lib/http/listener_impl.h
src/lib/http/tests/http_server_test.h

index 18f81f529cc9748d053805a3ba47100d133cd7c8..9c05e996898b1ec0e7b88bdbb529681d4364545e 100644 (file)
@@ -42,6 +42,11 @@ HttpListener::getLocalPort() const {
     return (impl_->getEndpoint().getPort());
 }
 
+const TlsContextPtr&
+HttpListener::getTlsContext() const {
+    return (impl_->getTlsContext());
+}
+
 int
 HttpListener::getNative() const {
     return (impl_->getNative());
index b842d7f18d9cb5a4e72cc029960ce7ddbf1bbf12..9f35e626426077f8ffccf5663de83e4bfac32827 100644 (file)
@@ -115,6 +115,9 @@ public:
     /// @brief Returns local port on which server is listening.
     uint16_t getLocalPort() const;
 
+    /// @brief Returns reference to the current TLS context.
+    const asiolink::TlsContextPtr& getTlsContext() const;
+
     /// @brief file descriptor of the underlying acceptor socket.
     int getNative() const;
 
index 70535ef7e56e7236906e3e5d5d76b6a1151900a8..85fd74ee3dcfe825a1e654db11156e621f82cd66 100644 (file)
@@ -70,6 +70,11 @@ HttpListenerImpl::getEndpoint() const {
     return (*endpoint_);
 }
 
+const TlsContextPtr&
+HttpListenerImpl::getTlsContext() const {
+    return (tls_context_);
+}
+
 int
 HttpListenerImpl::getNative() const {
     return (acceptor_ ? acceptor_->getNative() : -1);
index 73f70dc50764dbb0ccb8174384aaaa7034d20903..f36a1330b81b791e05b928faec8bdc3105c03617 100644 (file)
@@ -60,6 +60,9 @@ public:
     /// @brief Returns reference to the current listener endpoint.
     const asiolink::TCPEndpoint& getEndpoint() const;
 
+    /// @brief Returns reference to the current TLS context.
+    const asiolink::TlsContextPtr& getTlsContext() const;
+
     /// @brief file descriptor of the underlying acceptor socket.
     int getNative() const;
 
index 48c0671400a92610f83d1ce84fabf485f7496124..bd59d61ce34f59d08e4edc6036fe0dff0241923e 100644 (file)
@@ -392,6 +392,7 @@ public:
         ASSERT_NO_THROW(listener.start());
         ASSERT_EQ(SERVER_ADDRESS, listener.getLocalAddress().toText());
         ASSERT_EQ(SERVER_PORT, listener.getLocalPort());
+        ASSERT_EQ(server_context_, listener.getTlsContext());
         ASSERT_NO_THROW(startRequest(request));
         ASSERT_NO_THROW(runIOService());
         ASSERT_EQ(1, clients_.size());