]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix broken ssl_crtd helper interface
authorChristos Tsantilas <chtsanti@users.sourceforge.net>
Wed, 7 Nov 2012 19:26:45 +0000 (21:26 +0200)
committerChristos Tsantilas <chtsanti@users.sourceforge.net>
Wed, 7 Nov 2012 19:26:45 +0000 (21:26 +0200)
With the patch r12422 which added support for OK/ERR/BH  helper response codes,
the ssl_crtd interface become broken. The ConnStateData::sslCrtdHandleReply
ssl_crtd reply handler, expects a response code included at the beggining of
the returned message. This is not true after the changes.

This patch add a parameter in Ssl::CrtdMessage constructor to define a message
as "ssl_crtd reply" or "ssl_crtd request" message. For ssl_crtd reply messages
the message parser does not expect helper response code.

This is a Measurement Factory project

src/client_side.cc
src/ssl/crtd_message.cc
src/ssl/crtd_message.h
src/ssl/ssl_crtd.cc

index 0ec0ece14a530c18eb92a8dffa5acc038b9dd4e6..c7a4a953c9f3084bfe34d8027843872a9d581eb9 100644 (file)
@@ -3701,7 +3701,7 @@ ConnStateData::sslCrtdHandleReply(const HelperReply &reply)
     if (!reply.other().hasContent()) {
         debugs(1, DBG_IMPORTANT, HERE << "\"ssl_crtd\" helper return <NULL> reply");
     } else {
-        Ssl::CrtdMessage reply_message;
+        Ssl::CrtdMessage reply_message(Ssl::CrtdMessage::REPLY);
         if (reply_message.parse(reply.other().content(), reply.other().contentSize()) != Ssl::CrtdMessage::OK) {
             debugs(33, 5, HERE << "Reply from ssl_crtd for " << sslConnectHostOrIp << " is incorrect");
         } else {
@@ -3837,7 +3837,7 @@ ConnStateData::getSslContextStart()
 #if USE_SSL_CRTD
         try {
             debugs(33, 5, HERE << "Generating SSL certificate for " << certProperties.commonName << " using ssl_crtd.");
-            Ssl::CrtdMessage request_message;
+            Ssl::CrtdMessage request_message(Ssl::CrtdMessage::REQUEST);
             request_message.setCode(Ssl::CrtdMessage::code_new_certificate);
             request_message.composeRequest(certProperties);
             debugs(33, 5, HERE << "SSL crtd request: " << request_message.compose().c_str());
index 29fb59a11151e0c12ea1c51b42ad1217eab87380..575953037399d2f31d8df5ce402d3542bf5ae559 100644 (file)
@@ -11,8 +11,8 @@
 #include <stdexcept>
 #endif
 
-Ssl::CrtdMessage::CrtdMessage()
-        :   body_size(0), state(BEFORE_CODE)
+Ssl::CrtdMessage::CrtdMessage(MessageKind kind)
+        :   body_size(0), state(kind == REPLY ? BEFORE_LENGTH: BEFORE_CODE)
 {}
 
 Ssl::CrtdMessage::ParseResult Ssl::CrtdMessage::parse(const char * buffer, size_t len)
index 41bd78fb9e74dddc1a6e999210a039e584a8265b..bffcf847c5774a2e2d7534ca9d138d31643b7470 100644 (file)
@@ -27,7 +27,11 @@ public:
         INCOMPLETE,
         ERROR
     };
-    CrtdMessage();
+    enum MessageKind {
+        REPLY,
+        REQUEST
+    };
+    CrtdMessage(MessageKind kind);
     /**Parse buffer of length len
      \retval OK          if parsing completes
      \retval INCOMPLETE  if more data required
index 0bd9a7edac0f021cbb2199d849cebcb399a767bc..e48f9f8fd2c3d96d7c41f207cd923af570a02526 100644 (file)
@@ -232,7 +232,7 @@ static bool proccessNewRequest(Ssl::CrtdMessage & request_message, std::string c
     if (!Ssl::writeCertAndPrivateKeyToMemory(cert, pkey, bufferToWrite))
         throw std::runtime_error("Cannot write ssl certificate or/and private key to memory.");
 
-    Ssl::CrtdMessage response_message;
+    Ssl::CrtdMessage response_message(Ssl::CrtdMessage::REPLY);
     response_message.setCode("OK");
     response_message.setBody(bufferToWrite);
 
@@ -301,7 +301,7 @@ int main(int argc, char *argv[])
         // proccess request.
         for (;;) {
             char request[HELPER_INPUT_BUFFER];
-            Ssl::CrtdMessage request_message;
+            Ssl::CrtdMessage request_message(Ssl::CrtdMessage::REQUEST);
             Ssl::CrtdMessage::ParseResult parse_result = Ssl::CrtdMessage::INCOMPLETE;
 
             while (parse_result == Ssl::CrtdMessage::INCOMPLETE) {