From d82735391666c00061e31d279cef7b6e24debad8 Mon Sep 17 00:00:00 2001 From: John Kelly Date: Mon, 13 Aug 2012 07:50:58 -0700 Subject: [PATCH 1/2] Reverted previous change. Added sslverifypeer to subclasses of Socket's config array. --- src/Client/Adapter/Proxy.php | 22 ++++++++++++---------- src/Client/Adapter/Socket.php | 2 +- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/Client/Adapter/Proxy.php b/src/Client/Adapter/Proxy.php index d7ddb25210..753285395c 100644 --- a/src/Client/Adapter/Proxy.php +++ b/src/Client/Adapter/Proxy.php @@ -34,16 +34,18 @@ class Proxy extends Socket * @var array */ protected $config = array( - 'ssltransport' => 'ssl', - 'sslcert' => null, - 'sslpassphrase' => null, - 'sslusecontext' => false, - 'proxy_host' => '', - 'proxy_port' => 8080, - 'proxy_user' => '', - 'proxy_pass' => '', - 'proxy_auth' => Client::AUTH_BASIC, - 'persistent' => false + 'ssltransport' => 'ssl', + 'sslcert' => null, + 'sslpassphrase' => null, + 'sslverifypeer' => true, + 'sslallowselfsigned' => false, + 'sslusecontext' => false, + 'proxy_host' => '', + 'proxy_port' => 8080, + 'proxy_user' => '', + 'proxy_pass' => '', + 'proxy_auth' => Client::AUTH_BASIC, + 'persistent' => false ); /** diff --git a/src/Client/Adapter/Socket.php b/src/Client/Adapter/Socket.php index 29730a622c..d925b33570 100644 --- a/src/Client/Adapter/Socket.php +++ b/src/Client/Adapter/Socket.php @@ -184,7 +184,7 @@ public function connect($host, $port = 80, $secure = false) if (! is_resource($this->socket) || ! $this->config['keepalive']) { $context = $this->getStreamContext(); if ($secure || $this->config['sslusecontext']) { - if (isset($this->config['sslverifypeer']) && $this->config['sslverifypeer'] !== null) { + if ($this->config['sslverifypeer'] !== null) { if (! stream_context_set_option($context, 'ssl', 'verify_peer', $this->config['sslverifypeer'])) { throw new AdapterException\RuntimeException('Unable to set sslverifypeer option'); From 1db9cc9c7bc94de53c448bc14b6db4f9b806f930 Mon Sep 17 00:00:00 2001 From: John Kelly Date: Mon, 13 Aug 2012 11:56:07 -0700 Subject: [PATCH 2/2] Added unit test --- test/Client/ProxyAdapterTest.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/test/Client/ProxyAdapterTest.php b/test/Client/ProxyAdapterTest.php index 4b93f3821e..b39e2795bd 100644 --- a/test/Client/ProxyAdapterTest.php +++ b/test/Client/ProxyAdapterTest.php @@ -87,8 +87,8 @@ public function testFallbackToSocket() )); $this->client->setUri($this->baseuri . 'testGetLastRequest.php'); - $res = $this->client->request(Client::TRACE); - if ($res->getStatus() == 405 || $res->getStatus() == 501) { + $res = $this->client->setMethod(\Zend\Http\Request::METHOD_TRACE)->send(); + if ($res->getStatusCode() == 405 || $res->getStatusCode() == 501) { $this->markTestSkipped('Server does not allow the TRACE method'); } @@ -103,4 +103,11 @@ public function testGetLastRequest() * the TRACE response */ } + + public function testDefaultConfig() + { + $config = $this->_adapter->getConfig(); + $this->assertEquals(TRUE, $config['sslverifypeer']); + $this->assertEquals(FALSE, $config['sslallowselfsigned']); + } }