allow to set verify_peer ssl options in Zend_Service_Tine20
authorPhilipp Schüle <p.schuele@metaways.de>
Tue, 1 Aug 2017 07:58:57 +0000 (09:58 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Tue, 1 Aug 2017 08:08:24 +0000 (10:08 +0200)
... and other services that use Zend_Http_Client

Change-Id: I3fb31fb4d0faa70e01ca7a2448578a8ba9abc577

tine20/library/Zend/Http/Client/Adapter/Socket.php
tine20/library/zf1ext/Zend/Service/Tine20.php

index 9c5d536..8008bc2 100644 (file)
@@ -62,10 +62,12 @@ class Zend_Http_Client_Adapter_Socket implements Zend_Http_Client_Adapter_Interf
      * @var array
      */
     protected $config = array(
-        'persistent'    => false,
-        'ssltransport'  => 'ssl',
-        'sslcert'       => null,
-        'sslpassphrase' => null
+        'persistent'        => false,
+        'ssltransport'      => 'ssl',
+        'sslcert'           => null,
+        'sslpassphrase'     => null,
+        'verify_peer'       => true,
+        'verify_peer_name'  => true,
     );
 
     /**
@@ -181,18 +183,12 @@ class Zend_Http_Client_Adapter_Socket implements Zend_Http_Client_Adapter_Interf
         if (! is_resource($this->socket) || ! $this->config['keepalive']) {
             $context = $this->getStreamContext();
             if ($secure) {
-                if ($this->config['sslcert'] !== null) {
-                    if (! stream_context_set_option($context, 'ssl', 'local_cert',
-                                                    $this->config['sslcert'])) {
-                        require_once 'Zend/Http/Client/Adapter/Exception.php';
-                        throw new Zend_Http_Client_Adapter_Exception('Unable to set sslcert option');
-                    }
-                }
-                if ($this->config['sslpassphrase'] !== null) {
-                    if (! stream_context_set_option($context, 'ssl', 'passphrase',
-                                                    $this->config['sslpassphrase'])) {
-                        require_once 'Zend/Http/Client/Adapter/Exception.php';
-                        throw new Zend_Http_Client_Adapter_Exception('Unable to set sslpassphrase option');
+                foreach (array('sslcert', 'sslpassphrase', 'verify_peer', 'verify_peer_name') as $sslOption) {
+                    if (isset($this->config[$sslOption]) && $this->config[$sslOption] !== null) {
+                        if (! stream_context_set_option($context, 'ssl', $sslOption, $this->config[$sslOption])) {
+                            require_once 'Zend/Http/Client/Adapter/Exception.php';
+                            throw new Zend_Http_Client_Adapter_Exception('Unable to set ' . $sslOption .' option');
+                        }
                     }
                 }
             }
index 7a31fa4..1832cd9 100644 (file)
  * @category   Zend
  * @package    Zend_Service
  * @author     Lars Kneschke <l.kneschke@metaways.de>
- * @copyright  Copyright (c) 2009-2012 Metaways Infosystems GmbH (http://www.metaways.de)
+ * @copyright  Copyright (c) 2009-2017 Metaways Infosystems GmbH (http://www.metaways.de)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ *
+ * pass some options to Zend_Http_Client like this:
+ *
+ *   $tineService = new Zend_Service_Tine20(null, new Zend_Http_Client(null, array(
+ *       'verify_peer' => false,
+ *       'verify_peer_name' => false,
+ *   )));
  */
 class Zend_Service_Tine20 extends Zend_Json_Client
 {