From 07a7264e102d210757b84354983a9100786cd997 Mon Sep 17 00:00:00 2001 From: Evgeny Kuzin Date: Thu, 7 Aug 2025 13:08:17 -0400 Subject: [PATCH 1/2] respect ssl settings for monitor connections --- lib/PgSQL_Monitor.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/lib/PgSQL_Monitor.cpp b/lib/PgSQL_Monitor.cpp index 4db02cf77a..9be8f1ea90 100644 --- a/lib/PgSQL_Monitor.cpp +++ b/lib/PgSQL_Monitor.cpp @@ -874,14 +874,22 @@ string build_conn_str(const task_st_t& task_st) { const mon_srv_t& srv_info { task_st.op_st.srv_info }; const mon_user_t& user_info { task_st.op_st.user_info }; - return string { + string conn_str = "host='" + srv_info.addr + "' " - + "port='" + std::to_string(srv_info.port) + "' " - + "user='" + user_info.user + "' " - + "password='" + user_info.pass + "' " - + "dbname='" + user_info.dbname + "' " - + "application_name=ProxySQL-Monitor" - }; + + "port='" + std::to_string(srv_info.port) + "' " + + "user='" + user_info.user + "' " + + "password='" + user_info.pass + "' " + + "dbname='" + user_info.dbname + "' " + + "application_name=ProxySQL-Monitor "; + + // Add SSL configuration based on server's use_ssl setting + if (srv_info.ssl) { + conn_str += "sslmode=require "; + } else { + conn_str += "sslmode=disable "; + } + + return conn_str; } pgsql_conn_t create_new_conn(task_st_t& task_st) { From 48fdd2e0c32dbbf380d7c3c1308deb767a5262d7 Mon Sep 17 00:00:00 2001 From: Evgeny Kuzin Date: Thu, 7 Aug 2025 13:16:21 -0400 Subject: [PATCH 2/2] addressing gemini concern --- lib/PgSQL_Monitor.cpp | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/lib/PgSQL_Monitor.cpp b/lib/PgSQL_Monitor.cpp index 9be8f1ea90..7090ecad39 100644 --- a/lib/PgSQL_Monitor.cpp +++ b/lib/PgSQL_Monitor.cpp @@ -874,22 +874,15 @@ string build_conn_str(const task_st_t& task_st) { const mon_srv_t& srv_info { task_st.op_st.srv_info }; const mon_user_t& user_info { task_st.op_st.user_info }; - string conn_str = + return string { "host='" + srv_info.addr + "' " + "port='" + std::to_string(srv_info.port) + "' " + "user='" + user_info.user + "' " + "password='" + user_info.pass + "' " + "dbname='" + user_info.dbname + "' " - + "application_name=ProxySQL-Monitor "; - - // Add SSL configuration based on server's use_ssl setting - if (srv_info.ssl) { - conn_str += "sslmode=require "; - } else { - conn_str += "sslmode=disable "; - } - - return conn_str; + + "application_name=ProxySQL-Monitor " + + (srv_info.ssl ? "sslmode=require " : "sslmode=disable ") + }; } pgsql_conn_t create_new_conn(task_st_t& task_st) {