]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix ssl cert validator response codes
authorChristos Tsantilas <chtsanti@users.sourceforge.net>
Thu, 27 Sep 2012 14:27:44 +0000 (17:27 +0300)
committerChristos Tsantilas <chtsanti@users.sourceforge.net>
Thu, 27 Sep 2012 14:27:44 +0000 (17:27 +0300)
Cert validator should return:
 - "OK" in case none certificate error found
 - "ERR" in case one or more SSL certificate errors found
 - "BH" in case of internal helper error

helpers/ssl/cert_valid.pl
src/forward.cc

index 00ba684e9204577acb02192d0672b0f312afdcca..78fa31d7749ee631e744763aa94c4533ebfda3ec 100644 (file)
@@ -26,6 +26,7 @@ while (<>) {
     }
 
     my $response;
+    my $haserror = 0;
     my $code = $line_args[0];
     my $bodylen = $line_args[1];
     my $body = $line_args[2] . "\n";
@@ -62,6 +63,7 @@ while (<>) {
 
         # Echo back the errors: fill the responseErrors array  with the errors we read.
         foreach $err (@errors) {
+            $haserror = 1;
             appendError (\@responseErrors, 
                          $err, #The error name
                          "Checked by Cert Validator", # An error reason
@@ -71,9 +73,13 @@ while (<>) {
 
         $response = createResponse(\@responseErrors);
         my $len = length($response);
-        $response = "OK ".$len." ".$response."\1";
+        if ($haserror) {
+            $response = "ERR ".$len." ".$response."\1";
+        } else {
+            $response = "OK ".$len." ".$response."\1";
+        }
     } else {
-        $response = "ERROR 0 \1";
+        $response = "BH 0 \1";
     }
 
     print $response;
index 8731dc7f9c276470030993fd0b27446e225963bd..c5d7d7f61977ac1518f738066642f63ecf354a79 100644 (file)
@@ -838,16 +838,19 @@ FwdState::sslCrtvdHandleReply(const char *reply)
             debugs(83, 5, HERE << "Reply from ssl_crtvd for " << request->GetHost() << " is incorrect");
             validatorFailed = true;
         } else {
-            if (replyMsg.getCode() != "OK") {
-                debugs(83, 5, HERE << "Certificate for " << request->GetHost() << " cannot be validated. ssl_crtvd response: " << replyMsg.getBody());
-                validatorFailed = true;
-            } else {
+            if (replyMsg.getCode() == "OK") {
                 debugs(83, 5, HERE << "Certificate for " << request->GetHost() << " was successfully validated from ssl_crtvd");
+            } else if (replyMsg.getCode() == "ERR") {
+                debugs(83, 5, HERE << "Certificate for " << request->GetHost() << " found buggy by ssl_crtvd");
                 errs = sslCrtvdCheckForErrors(validationResponse, errDetails);
-                if (!errDetails) {
-                    dispatch();
-                    return;
-                }
+            } else {
+                debugs(83, 5, HERE << "Certificate for " << request->GetHost() << " cannot be validated. ssl_crtvd response: " << replyMsg.getBody());
+                validatorFailed = true;
+            }
+
+            if (!errDetails && !validatorFailed) {
+                dispatch();
+                return;
             }
         }
     }