From cab35b2dea0031ba6cf80cdb8a45d91b3bc2a37f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Mon, 27 May 2019 20:21:24 +0300 Subject: [PATCH] MXS-2486: Fix listener serialization The serialization should be done via the parameters. This also makes SSLContext::serialize redundant. --- include/maxscale/ssl.hh | 7 ------- server/core/listener.cc | 14 ++------------ server/core/ssl.cc | 23 ----------------------- 3 files changed, 2 insertions(+), 42 deletions(-) diff --git a/include/maxscale/ssl.hh b/include/maxscale/ssl.hh index e9a7b4b9b..04c060e26 100644 --- a/include/maxscale/ssl.hh +++ b/include/maxscale/ssl.hh @@ -103,13 +103,6 @@ public: */ static std::unique_ptr create(const MXS_CONFIG_PARAMETER& params); - /** - * Serialize the SSL configuration into a INI file section - * - * @return SSLContext as a INI file section - */ - std::string serialize() const; - /** * Opens a new OpenSSL session for this configuration context */ diff --git a/server/core/listener.cc b/server/core/listener.cc index 3e428f28a..373844dd6 100644 --- a/server/core/listener.cc +++ b/server/core/listener.cc @@ -472,20 +472,10 @@ bool Listener::create_listener_config(const char* filename) // TODO: Check for return values on all of the dprintf calls dprintf(file, "[%s]\n", m_name.c_str()); dprintf(file, "type=listener\n"); - dprintf(file, "protocol=%s\n", m_protocol.c_str()); - dprintf(file, "service=%s\n", m_service->name()); - dprintf(file, "address=%s\n", m_address.c_str()); - dprintf(file, "port=%u\n", m_port); - dprintf(file, "authenticator=%s\n", m_authenticator.c_str()); - if (!m_auth_options.empty()) + for (const auto& p : m_params) { - dprintf(file, "authenticator_options=%s\n", m_auth_options.c_str()); - } - - if (ssl().context()) - { - dprintf(file, "%s", ssl().context()->serialize().c_str()); + dprintf(file, "%s=%s\n", p.first.c_str(), p.second.c_str()); } ::close(file); diff --git a/server/core/ssl.cc b/server/core/ssl.cc index 6d000338d..b57df3f2a 100644 --- a/server/core/ssl.cc +++ b/server/core/ssl.cc @@ -234,29 +234,6 @@ SSLContext::SSLContext(const SSLConfig& cfg) { } -std::string SSLContext::serialize() const -{ - std::ostringstream ss; - ss << "ssl=required\n"; - - if (!m_cfg.cert.empty()) - { - ss << "ssl_cert=" << m_cfg.cert << "\n"; - } - - if (!m_cfg.key.empty()) - { - ss << "ssl_key=" << m_cfg.key << "\n"; - } - - mxb_assert(!m_cfg.ca.empty()); - ss << "ssl_ca_cert=" << m_cfg.ca << "\n"; - ss << "ssl_version=" << ssl_method_type_to_string(m_cfg.version) << "\n"; - ss << "ssl_cert_verify_depth=" << m_cfg.verify_depth << "\n"; - ss << "ssl_verify_peer_certificate=" << (m_cfg.verify_peer ? "true" : "false") << "\n"; - return ss.str(); -} - bool SSLContext::init() { bool rval = true;