diff --git a/README.md b/README.md index 69284a1..669642b 100644 --- a/README.md +++ b/README.md @@ -185,6 +185,8 @@ Example config: 'timeout' => 3, // the token must match 'upload.token' config in XHGui 'token' => 'token', + // verify option to disable ssl verification, defaults to true if unspecified. + 'verify' => true, ), ``` diff --git a/src/Saver/UploadSaver.php b/src/Saver/UploadSaver.php index c236646..a22bd1a 100644 --- a/src/Saver/UploadSaver.php +++ b/src/Saver/UploadSaver.php @@ -10,8 +10,10 @@ final class UploadSaver implements SaverInterface private $url; /** @var int */ private $timeout; + /** @var bool */ + private $verify; - public function __construct($url, $token, $timeout) + public function __construct($url, $token, $timeout, $verify) { $this->url = $url; if ($token) { @@ -19,6 +21,7 @@ public function __construct($url, $token, $timeout) } $this->timeout = $timeout; + $this->verify = $verify; } public function isSupported() @@ -64,6 +67,7 @@ private function submit($url, $payload) CURLOPT_FOLLOWLOCATION => 1, CURLOPT_HTTPHEADER => $headers, CURLOPT_TIMEOUT => $this->timeout, + CURLOPT_SSL_VERIFYPEER => $this->verify, )); if (!$res) { $error = curl_errno($ch) ? curl_error($ch) : ''; diff --git a/src/SaverFactory.php b/src/SaverFactory.php index f8cd688..71fbf30 100644 --- a/src/SaverFactory.php +++ b/src/SaverFactory.php @@ -35,10 +35,16 @@ public static function create($saveHandler, Config $config) 'url' => null, 'token' => null, 'timeout' => 3, + 'verify' => true, ); $userConfig = isset($config['save.handler.upload']) && is_array($config['save.handler.upload']) ? $config['save.handler.upload'] : array(); $saverConfig = array_merge($defaultConfig, $userConfig); - $saver = new Saver\UploadSaver($saverConfig['url'] ?: $saverConfig['uri'], $saverConfig['token'], $saverConfig['timeout']); + $saver = new Saver\UploadSaver( + $saverConfig['url'] ?: $saverConfig['uri'], + $saverConfig['token'], + $saverConfig['timeout'], + $saverConfig['verify'] + ); break; case Profiler::SAVER_STACK: