]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Move SSL squid.conf option parse into Security::PeerOptions
authorAmos Jeffries <squid3@treenet.co.nz>
Fri, 14 Nov 2014 16:42:45 +0000 (08:42 -0800)
committerAmos Jeffries <squid3@treenet.co.nz>
Fri, 14 Nov 2014 16:42:45 +0000 (08:42 -0800)
src/cache_cf.cc
src/security/PeerOptions.cc
src/security/PeerOptions.h
src/tests/stub_libsecurity.cc

index 74c60b5b4e28e8b338f6454e6e77948db6801a4f..a5ec5ab3441380b5179c98863e934e678b525e77 100644 (file)
@@ -2244,32 +2244,7 @@ parse_peer(CachePeer ** head)
             debugs(0, DBG_CRITICAL, "WARNING: cache_peer option '" << token << "' requires --with-openssl");
 #else
             p->secure.ssl = true;
-
-        if (strncmp(token, "sslcert=", 8) == 0) {
-            p->secure.certFile = SBuf(token + 8);
-        } else if (strncmp(token, "sslkey=", 7) == 0) {
-            p->secure.privateKeyFile = SBuf(token + 7);
-            if (p->secure.certFile.isEmpty()) {
-                debugs(0, DBG_PARSE_NOTE(1), "WARNING: cache_peer 'sslcert=' option needs to be set before 'sslkey=' is used.");
-                p->secure.certFile = p->secure.privateKeyFile;
-            }
-        } else if (strncmp(token, "sslversion=", 11) == 0) {
-            p->secure.sslVersion = xatoi(token + 11);
-        } else if (strncmp(token, "ssloptions=", 11) == 0) {
-            p->secure.sslOptions = SBuf(token + 11);
-        } else if (strncmp(token, "sslcipher=", 10) == 0) {
-            p->secure.sslCipher = SBuf(token + 10);
-        } else if (strncmp(token, "sslcafile=", 10) == 0) {
-            p->secure.caFile = SBuf(token + 10);
-        } else if (strncmp(token, "sslcapath=", 10) == 0) {
-            p->secure.caDir = SBuf(token + 10);
-        } else if (strncmp(token, "sslcrlfile=", 11) == 0) {
-            p->secure.crlFile = SBuf(token + 11);
-        } else if (strncmp(token, "sslflags=", 9) == 0) {
-            p->secure.sslFlags = SBuf(token + 9);
-        } else if (strncmp(token, "ssldomain=", 10) == 0) {
-            p->secure.sslDomain = SBuf(token + 10);
-        }
+            p->secure.parse(token+3);
 #endif
 
         } else if (strcmp(token, "front-end-https") == 0) {
index 8f989a236bb1c64f296d250da8c7205b748d045b..32f549d5a5b083298a04edac65de8409353adb21 100644 (file)
@@ -7,12 +7,45 @@
  */
 
 #include "squid.h"
+#include "Debug.h"
+#include "globals.h"
+#include "Parsing.h"
 #include "security/PeerOptions.h"
 
 #if USE_OPENSSL
 #include "ssl/support.h"
 #endif
 
+void
+Security::PeerOptions::parse(const char *token)
+{
+    if (strncmp(token, "cert=", 5) == 0) {
+        certFile = SBuf(token + 5);
+    } else if (strncmp(token, "key=", 4) == 0) {
+        privateKeyFile = SBuf(token + 4);
+        if (certFile.isEmpty()) {
+            debugs(0, DBG_PARSE_NOTE(1), "WARNING: cert= option needs to be set before key= is used.");
+            certFile = privateKeyFile;
+        }
+    } else if (strncmp(token, "version=", 8) == 0) {
+        sslVersion = xatoi(token + 8);
+    } else if (strncmp(token, "options=", 8) == 0) {
+        sslOptions = SBuf(token + 8);
+    } else if (strncmp(token, "cipher=", 7) == 0) {
+        sslCipher = SBuf(token + 7);
+    } else if (strncmp(token, "cafile=", 7) == 0) {
+        caFile = SBuf(token + 7);
+    } else if (strncmp(token, "capath=", 7) == 0) {
+        caDir = SBuf(token + 7);
+    } else if (strncmp(token, "crlfile=", 8) == 0) {
+        crlFile = SBuf(token + 8);
+    } else if (strncmp(token, "flags=", 6) == 0) {
+        sslFlags = SBuf(token + 6);
+    } else if (strncmp(token, "domain=", 7) == 0) {
+        sslDomain = SBuf(token + 7);
+    }
+}
+
 // XXX: make a GnuTLS variant
 Security::ContextPointer
 Security::PeerOptions::createContext()
index fba2758a043ef8271e0720a6eb943a6785313b0d..1730214a9e66d8ab92f340bd42d6d2fb33fc8073 100644 (file)
@@ -20,6 +20,9 @@ class PeerOptions
 public:
     PeerOptions() : ssl(false), sslVersion(0) {}
 
+    /// parse a TLS squid.conf option
+    void parse(const char *);
+
     /// generate a security context from the configured options
     Security::ContextPointer createContext();
 
index a6b586ff683277ee57df914f3641d3c614f55ed5..b202d842084e6a26dab9bad040800aa76134f3d0 100644 (file)
@@ -12,4 +12,5 @@
 #include "tests/STUB.h"
 
 #include "security/PeerOptions.h"
+void Security::PeerOptions::parse(char const*) STUB
 Security::ContextPointer Security::PeerOptions::createContext() STUB_RETVAL(NULL)