Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds SSL/TLS support to the example HTTP server by implementing an SSL worker class and certificate management functionality. The changes enable the server to handle secure HTTPS connections alongside existing HTTP functionality.
Key changes include:
- Implementation of SSL worker class with SSL stream handling
- Certificate loading and SSL context management
- Refactoring of existing worker class to support protocol templates
- Addition of SSL dependencies and certificate files
Reviewed Changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| example/server/worker_ssl.hpp | New SSL worker implementation with SSL stream handling and handshake logic |
| example/server/worker.hpp | Refactored to use protocol templates and moved member declarations to bottom |
| example/server/main.cpp | Added SSL context setup and SSL worker instantiation |
| example/server/logger.hpp | Added header guards to prevent macro redefinition |
| example/server/handler.hpp | Added boost namespace wrapper and new HTTPS redirect function |
| example/server/handler.cpp | Enhanced error handling with proper HTTP-date formatting and updated function signatures |
| example/server/certificate.hpp | New header for SSL certificate loading functionality |
| example/server/certificate.cpp | Implementation of certificate loading with embedded test certificates |
| example/server/CMakeLists.txt | Added OpenSSL dependencies |
| Various certificate files | Test certificates and keys for SSL functionality |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| LOG_TRC(sect_, id(), "async_accept, error::operation_aborted"); | ||
| return; | ||
| } | ||
|
|
||
| // happens periodically, usually harmless | ||
| LOG_DBG(sect_, id(), "async_accept ", ec.message()); |
There was a problem hiding this comment.
The log message 'async_accept' is incorrect in the handshake error handler. This should be 'async_handshake' to accurately reflect the operation that failed.
| LOG_TRC(sect_, id(), "async_accept, error::operation_aborted"); | |
| return; | |
| } | |
| // happens periodically, usually harmless | |
| LOG_DBG(sect_, id(), "async_accept ", ec.message()); | |
| LOG_TRC(sect_, id(), "async_handshake, error::operation_aborted"); | |
| return; | |
| } | |
| // happens periodically, usually harmless | |
| LOG_DBG(sect_, id(), "async_handshake ", ec.message()); |
| LOG_TRC(sect_, id(), "async_accept, error::operation_aborted"); | ||
| return; | ||
| } | ||
|
|
||
| // happens periodically, usually harmless | ||
| LOG_DBG(sect_, id(), "async_accept ", ec.message()); |
There was a problem hiding this comment.
The log message 'async_accept' is incorrect in the handshake error handler. This should be 'async_handshake' to accurately reflect the operation that failed.
| LOG_TRC(sect_, id(), "async_accept, error::operation_aborted"); | |
| return; | |
| } | |
| // happens periodically, usually harmless | |
| LOG_DBG(sect_, id(), "async_accept ", ec.message()); | |
| LOG_TRC(sect_, id(), "async_handshake, error::operation_aborted"); | |
| return; | |
| } | |
| // happens periodically, usually harmless | |
| LOG_DBG(sect_, id(), "async_handshake ", ec.message()); |
| private: | ||
| // order of destruction matters here | ||
| section sect_; | ||
| asio_server& srv_; | ||
| asio::ssl::context& ssl_ctx_; | ||
| acceptor_type* pa_ = nullptr; | ||
| stream_type stream_; | ||
| typename Protocol::endpoint ep_; | ||
| std::string const& doc_root_; | ||
| http_proto::request_parser pr_; | ||
| http_proto::response res_; | ||
| http_proto::serializer sr_; | ||
| std::size_t id_ = 0; | ||
| }; |
There was a problem hiding this comment.
There are two 'private:' access specifiers in the class (lines 103 and 312), which is unnecessary. Consider consolidating the private members under a single private section.
| private: | |
| // order of destruction matters here | |
| section sect_; | |
| asio_server& srv_; | |
| asio::ssl::context& ssl_ctx_; | |
| acceptor_type* pa_ = nullptr; | |
| stream_type stream_; | |
| typename Protocol::endpoint ep_; | |
| std::string const& doc_root_; | |
| http_proto::request_parser pr_; | |
| http_proto::response res_; | |
| http_proto::serializer sr_; | |
| std::size_t id_ = 0; | |
| }; |
| http_proto::request_base const& req, | ||
| http_proto::response& res, | ||
| http_proto::serializer& sr) | ||
| { |
There was a problem hiding this comment.
The handle_https_redirect function is empty but lacks documentation explaining its intended behavior or why it's not implemented.
| { | |
| { | |
| // This function is intentionally left empty. | |
| // HTTPS redirection is not implemented in this example server. | |
| // Add implementation here if HTTPS support is required. |
No description provided.