[cpp-sp] 01/02: CPPSP-62 promote shared configuration to AbstractHTTPRemotingService

Codeberg noreply at shibboleth.net
Thu Aug 20 15:11:11 UTC 2026


This is an automated email from the git hooks/post-receive script.

codeberg pushed a commit to branch main
in repository cpp-sp.

View the commit online:
https://codeberg.org/Shibboleth/cpp-sp/commit/b0f8906807f8d281ff12bfd1005890dd23931f46

commit b0f8906807f8d281ff12bfd1005890dd23931f46
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Thu Aug 20 15:20:44 2026 +0100

    CPPSP-62 promote shared configuration to AbstractHTTPRemotingService
    
    https://shibboleth.atlassian.net/browse/CPPSP-62
    
    "tlsCipherList", "chunkedEncoding", "traceFileBase" all move from
    CurlHTTPRemotingService to AbstractHTTPRemotingService
    
    chunkedEncoding also moves from WinHttpRemoting and changes default.
---
 .../remoting/impl/AbstractHTTPRemotingService.cpp  | 28 +++++++++++++-
 shibsp/remoting/impl/AbstractHTTPRemotingService.h |  9 ++++-
 shibsp/remoting/impl/CurlHTTPRemotingService.cpp   | 44 +++++-----------------
 shibsp/remoting/impl/WinHTTPRemotingService.cpp    | 13 +------
 4 files changed, 46 insertions(+), 48 deletions(-)

diff --git a/shibsp/remoting/impl/AbstractHTTPRemotingService.cpp b/shibsp/remoting/impl/AbstractHTTPRemotingService.cpp
index 0ca30760..fa677192 100644
--- a/shibsp/remoting/impl/AbstractHTTPRemotingService.cpp
+++ b/shibsp/remoting/impl/AbstractHTTPRemotingService.cpp
@@ -39,7 +39,7 @@ using namespace boost::property_tree;
 using namespace std;
 
 AbstractHTTPRemotingService::AbstractHTTPRemotingService(ptree& pt)
-    : AbstractRemotingService(pt), m_authMethod(agent_auth_none)
+    : AbstractRemotingService(pt), m_authMethod(agent_auth_none), m_chunked(true)
 {
     BoostPropertySet props;
     props.load(pt);
@@ -56,6 +56,10 @@ AbstractHTTPRemotingService::AbstractHTTPRemotingService(ptree& pt)
     static const char REVOCATION_CHECK_PROP_NAME[] = "revocationCheck";
     static const char ENABLE_IP4_PROP_NAME[] = "enableIP4";
     static const char ENABLE_IP6_PROP_NAME[] = "enableIP6";
+    static const char CIPHER_LIST_PROP_NAME[] = "tlsCipherList";
+    static const char TLS13_CIPHER_LIST_PROP_NAME[] = "tls13CipherList";
+    static const char CHUNKED_PROP_NAME[] = "chunkedEncoding";
+    static const char TRACE_FILE_PROP_NAME[] = "traceFileBase";
 
     static const char AGENT_ID_PROP_DEFAULT[] = "localhost";
     static const char SECRET_SOURCE_TYPE_PROP_DEFAULT[] = FILE_SECRET_SOURCE;
@@ -69,6 +73,9 @@ AbstractHTTPRemotingService::AbstractHTTPRemotingService(ptree& pt)
     static const bool REVOCATION_CHECK_DEFAULT = false;
     static const bool ENABLE_IP4_PROP_DEFAULT = true;
     static const bool ENABLE_IP6_PROP_DEFAULT = true;
+    static const char CIPHER_LIST_PROP_DEFAULT[] = "";
+    static bool CHUNKED_PROP_DEFAULT = true;
+    static const char TRACE_FILE_PROP_DEFAULT[] = "";
 
     m_agentID = props.getString(AGENT_ID_PROP_NAME, AGENT_ID_PROP_DEFAULT);    
     m_userAgent = props.getString(USER_AGENT_PROP_NAME, USER_AGENT_PROP_DEFAULT);
@@ -83,6 +90,9 @@ AbstractHTTPRemotingService::AbstractHTTPRemotingService(ptree& pt)
     m_revocationCheck = props.getBool(REVOCATION_CHECK_PROP_NAME, REVOCATION_CHECK_DEFAULT);
     m_enableIP4 = props.getBool(ENABLE_IP4_PROP_NAME, ENABLE_IP4_PROP_DEFAULT);
     m_enableIP6 = props.getBool(ENABLE_IP6_PROP_NAME, ENABLE_IP6_PROP_DEFAULT);
+    m_chunked = props.getBool(CHUNKED_PROP_NAME, CHUNKED_PROP_DEFAULT);
+    m_ciphers = props.getString(CIPHER_LIST_PROP_NAME, CIPHER_LIST_PROP_DEFAULT);
+    m_traceFileBase = props.getString(TRACE_FILE_PROP_NAME, TRACE_FILE_PROP_DEFAULT);
 
     if (!m_enableIP4 && !m_enableIP6) {
         throw ConfigurationException("One of IP4 or IP6 must be enabled.");
@@ -230,6 +240,22 @@ bool AbstractHTTPRemotingService::isRevocationCheck() const
     return m_revocationCheck;
 }
 
+bool AbstractHTTPRemotingService::isChunked() const {
+    return m_chunked;
+}
+
+const string& AbstractHTTPRemotingService::getCiphers() const {
+    return m_ciphers;
+}
+
+const string& AbstractHTTPRemotingService::getTls13Ciphers() const {
+    return m_tls13Ciphers;
+}
+
+ const string& AbstractHTTPRemotingService::getTraceFileBase() const {
+    return m_traceFileBase;
+}
+
 const char* AbstractHTTPRemotingService::getCAFile() const
 {
     if (m_caFile.empty()) {
diff --git a/shibsp/remoting/impl/AbstractHTTPRemotingService.h b/shibsp/remoting/impl/AbstractHTTPRemotingService.h
index 690ec492..1ebd2171 100644
--- a/shibsp/remoting/impl/AbstractHTTPRemotingService.h
+++ b/shibsp/remoting/impl/AbstractHTTPRemotingService.h
@@ -71,7 +71,6 @@ namespace shibsp {
          * @return the base URL, with a terminating slash
          */
         const char* getBaseURL() const;
-
         const char* getUserAgent() const;
         void setUserAgent(const char* ua);
         auth_t getAuthMethod() const;
@@ -83,6 +82,10 @@ namespace shibsp {
         bool isRevocationCheck() const;
         bool isEnableIP4() const;
         bool isEnableIP6() const;
+        bool isChunked() const;
+        const std::string& getCiphers() const;
+        const std::string& getTls13Ciphers() const;
+        const std::string& getTraceFileBase() const;
 
     protected:
         AbstractHTTPRemotingService(boost::property_tree::ptree& pt);
@@ -103,6 +106,10 @@ namespace shibsp {
         bool m_revocationCheck;
         bool m_enableIP4;
         bool m_enableIP6;
+        bool m_chunked;
+        std::string m_ciphers;
+        std::string m_tls13Ciphers;
+        std::string m_traceFileBase;
         /** Shared lock for guarding auth cache value. */
 #if defined(HAVE_CXX17)
         std::unique_ptr<std::shared_mutex> m_authcachelock;
diff --git a/shibsp/remoting/impl/CurlHTTPRemotingService.cpp b/shibsp/remoting/impl/CurlHTTPRemotingService.cpp
index 5d1e6e92..40393e65 100644
--- a/shibsp/remoting/impl/CurlHTTPRemotingService.cpp
+++ b/shibsp/remoting/impl/CurlHTTPRemotingService.cpp
@@ -61,14 +61,6 @@ namespace {
             return m_log;
         }
 
-        const string& getTraceFileBase() const {
-            return m_traceFileBase;
-        }
-
-        bool isChunked() const {
-            return m_chunked;
-        }
-
         void send(const char* path, istream& input, ostream& output) const;
 
         CURL* checkout() const;
@@ -77,14 +69,10 @@ namespace {
 
     private:
         Category& m_log;
-        string m_traceFileBase;
         bool m_curlInit;
         mutable list<CURL*> m_pool;
         mutable int m_poolsize;
         mutable mutex m_lock;
-        string m_ciphers;
-        string m_tls13_ciphers;
-        bool m_chunked;
     };
 
     class SHIBSP_DLLLOCAL CurlOperation
@@ -175,7 +163,7 @@ CurlHTTPRemotingService::CurlHTTPRemotingService(ptree& pt) :
     AbstractRemotingService(pt),
     AbstractHTTPRemotingService(pt),
     m_log(Category::getInstance(SHIBSP_LOGCAT ".RemotingService")),
-        m_curlInit(false), m_poolsize(20), m_chunked(true)
+        m_curlInit(false), m_poolsize(20)
 {
 
     CURLcode status = curl_global_init(CURL_GLOBAL_ALL);
@@ -185,23 +173,9 @@ CurlHTTPRemotingService::CurlHTTPRemotingService(ptree& pt) :
     }
     m_curlInit = true;
 
-    static const char CIPHER_LIST_PROP_NAME[] = "tlsCipherList";
-    static const char TLS13_CIPHER_LIST_PROP_NAME[] = "tls13CipherList";
-    static const char CHUNKED_PROP_NAME[] = "chunkedEncoding";
-    static const char TRACE_FILE_PROP_NAME[] = "traceFileBase";
-
-    static const char CIPHER_LIST_PROP_DEFAULT[] = "";
-    static const char CIPHER_LIST_PROP_DEFAULT[] = "";
-    static bool CHUNKED_PROP_DEFAULT = true;
-    static const char TRACE_FILE_PROP_DEFAULT[] = "";
-
     BoostPropertySet props;
     props.load(pt);
 
-    m_chunked = props.getBool(CHUNKED_PROP_NAME, CHUNKED_PROP_DEFAULT);
-    m_ciphers = props.getString(CIPHER_LIST_PROP_NAME, CIPHER_LIST_PROP_DEFAULT);
-    m_tls13_ciphers = props.getString(TLS13_CIPHER_LIST_PROP_NAME, CIPHER_LIST_PROP_DEFAULT);
-
     if (getUserAgent() == nullptr) {
         string useragent = string(PACKAGE_NAME) + '/' + PACKAGE_VERSION;
         curl_version_info_data* curlver = curl_version_info(CURLVERSION_NOW);
@@ -213,11 +187,11 @@ CurlHTTPRemotingService::CurlHTTPRemotingService(ptree& pt) :
 
     m_log.info("CurlHTTP RemotingService installed for agent ID (%s), baseURL (%s)", getAgentID(), getBaseURL());
 
-    m_traceFileBase = props.getString(TRACE_FILE_PROP_NAME, TRACE_FILE_PROP_DEFAULT);
-    if (!m_traceFileBase.empty()) {
-        AgentConfig::getConfig().getPathResolver().resolve(m_traceFileBase, PathResolver::SHIBSP_LOG_FILE);
+    string base(getTraceFileBase());
+    if (!base.empty()) {
+        AgentConfig::getConfig().getPathResolver().resolve(base, PathResolver::SHIBSP_LOG_FILE);
         m_log.warn("tracing enabled (%s), sensitive information *will* be logged; do not share and protect appropriately",
-            m_traceFileBase.c_str());
+            base.c_str());
     }
 }
 
@@ -284,11 +258,11 @@ CURL* CurlHTTPRemotingService::checkout() const
 
     SHIB_CURL_SET(CURLOPT_SSL_VERIFYPEER, 1);
     SHIB_CURL_SET(CURLOPT_SSL_VERIFYHOST, 2);
-    if (!m_ciphers.empty()) {
-        SHIB_CURL_SET(CURLOPT_SSL_CIPHER_LIST, m_ciphers.c_str());
+    if (!getCiphers().empty()) {
+        SHIB_CURL_SET(CURLOPT_SSL_CIPHER_LIST, getCiphers().c_str());
     }
-    if (!m_tls13_ciphers.empty()) {
-        SHIB_CURL_SET(CURLOPT_TLS13_CIPHERS, m_tls13_ciphers.c_str());
+    if (!getTls13Ciphers().empty()) {
+        SHIB_CURL_SET(CURLOPT_TLS13_CIPHERS, getTls13Ciphers().c_str());
     }
     if (getCAFile()) {
         SHIB_CURL_SET(CURLOPT_CAINFO, getCAFile());
diff --git a/shibsp/remoting/impl/WinHTTPRemotingService.cpp b/shibsp/remoting/impl/WinHTTPRemotingService.cpp
index 5c6c0adf..ce718daf 100644
--- a/shibsp/remoting/impl/WinHTTPRemotingService.cpp
+++ b/shibsp/remoting/impl/WinHTTPRemotingService.cpp
@@ -46,8 +46,6 @@ using namespace std;
 # define strcasecmp _stricmp
 #endif
 
-constexpr bool defaultChunking(false);
-
 namespace {
 
     class SHIBSP_DLLLOCAL WinHTTPRemotingService : public virtual AbstractHTTPRemotingService {
@@ -55,10 +53,6 @@ namespace {
         WinHTTPRemotingService(ptree& pt);
         virtual ~WinHTTPRemotingService();
 
-        bool isChunked() const {
-            return m_chunked;
-        }
-
         wstring utf8ToUtf16(const char* input) const;
 
         void send(const char* path, istream& input, ostream& output) const;
@@ -73,7 +67,6 @@ namespace {
         HINTERNET m_session;
         HINTERNET m_connection;
         string m_ciphers;
-        bool m_chunked;
         bool m_secure;
         wstring m_baseURLPath;
         wstring m_username;
@@ -223,7 +216,7 @@ WinHTTPRemotingService::WinHTTPRemotingService(ptree& pt)
     AbstractHTTPRemotingService(pt),
     m_log(Category::getInstance(SHIBSP_LOGCAT ".RemotingService")),
     m_secure(false), m_caChainEngine(nullptr), m_caStore(nullptr),
-    m_init(false), m_chunked(defaultChunking)
+    m_init(false)
 {
     if (getUserAgent() == nullptr) {
         string useragent = string(PACKAGE_NAME) + '/' + PACKAGE_VERSION + '/' + "WINHTTP";
@@ -236,8 +229,6 @@ WinHTTPRemotingService::WinHTTPRemotingService(ptree& pt)
     BoostPropertySet props;
     props.load(pt);
 
-    m_chunked = props.getBool(CHUNKED_PROP_NAME, defaultChunking);
-    //m_ciphers = props.getString(CIPHER_LIST_PROP_NAME, "");
     m_username = utf8ToUtf16(getAgentID());
     switch (getAuthMethod()) {
         case agent_auth_basic:  m_authScheme = WINHTTP_AUTH_SCHEME_BASIC; break;
@@ -422,7 +413,7 @@ void WinHTTPRemotingService::send(const char* path, istream& input, ostream& out
         throw RemotingException("Send failed");
     }
 
-    if (m_chunked) {
+    if (isChunked()) {
         //
         // Send the request, then the chunked data
         //

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list