From c2974b82c5136465d279d3c7727b6400b4c955a1 Mon Sep 17 00:00:00 2001 From: Andy Thompson Date: Thu, 29 Oct 2015 13:44:45 +0000 Subject: [PATCH] Update Curl wrapper to verify_peer like PHP stream contexts does In order to simulate a standard SoapClient BesimpleSoap should turn peer verification on by default in PHP 5.6+ and allow this setting to be changed (switched off if in testing, or switched on for what the majority of PHP <= 5.5 has to do manually) --- src/BeSimple/SoapClient/Curl.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/BeSimple/SoapClient/Curl.php b/src/BeSimple/SoapClient/Curl.php index e777fc8f..d2ba833e 100644 --- a/src/BeSimple/SoapClient/Curl.php +++ b/src/BeSimple/SoapClient/Curl.php @@ -59,13 +59,17 @@ public function __construct(array $options = array(), $followLocationMaxRedirect if (!isset($options['user_agent'])) { $options['user_agent'] = self::USER_AGENT; } + // set the default ssl peer verification + if (!isset($options['verify_peer'])) { + $options['verify_peer'] = (version_compare(PHP_VERSION, '5.6.0') >= 0); + } $this->followLocationMaxRedirects = $followLocationMaxRedirects; // make http request $this->ch = curl_init(); $curlOptions = array( CURLOPT_ENCODING => '', - CURLOPT_SSL_VERIFYPEER => false, + CURLOPT_SSL_VERIFYPEER => $options['verify_peer'], CURLOPT_FAILONERROR => false, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,