#9004: sieve + tls problem: Could not authenticate
authorPhilipp Schüle <p.schuele@metaways.de>
Wed, 30 Apr 2014 12:13:35 +0000 (14:13 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Mon, 5 May 2014 08:10:50 +0000 (10:10 +0200)
... with user xy (Plaintext authentication disabled.)

* improves exception message as suggested by dragon
* makes ssl setting case insensitve

https://forge.tine20.org/mantisbt/view.php?id=9004

Change-Id: Ic2ea5c0803d204d8243399f1ec5bfcbc4eff97e6
Reviewed-on: http://gerrit.tine20.com/customers/589
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
Tested-by: Philipp Schüle <p.schuele@metaways.de>
tine20/Zend/Mail/Protocol/Sieve.php

index 6a17c81..0c1dc2f 100644 (file)
@@ -109,15 +109,19 @@ class Zend_Mail_Protocol_Sieve
         $this->_welcome = $this->readResponse();
         $this->_parseWelcomeArray();
 
-        if ($ssl === 'TLS') {
-            $result = $this->requestAndResponse('STARTTLS');
-            $result = $result && stream_socket_enable_crypto($this->_socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT);
-            if (!$result) {
+        if (strtoupper($ssl) === 'TLS') {
+            $result1 = $this->requestAndResponse('STARTTLS');
+            $result2 = stream_socket_enable_crypto($this->_socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT);
+            if (!$result2) {
                 /**
                  * @see Zend_Mail_Protocol_Exception
                  */
                 require_once 'Zend/Mail/Protocol/Exception.php';
-                throw new Zend_Mail_Protocol_Exception('cannot enable TLS');
+                $message = "requestAndResponse failed: $result1";
+                if (!$result1) {
+                   $message = "stream_socket_enable_crypto failed.";
+                }
+                throw new Zend_Mail_Protocol_Exception("cannot enable TLS: $message");
             }
         }