From fdd2e485c4b456ccd34861871547ad15db17fdae Mon Sep 17 00:00:00 2001 From: VicDeo Date: Wed, 2 Aug 2017 14:14:19 +0300 Subject: [PATCH] Skip SSL validation for https://localhost --- src/Utils/OccRunner.php | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/Utils/OccRunner.php b/src/Utils/OccRunner.php index f76b05c7..0230ea9d 100644 --- a/src/Utils/OccRunner.php +++ b/src/Utils/OccRunner.php @@ -92,16 +92,24 @@ public function runJson($command, $args = []){ protected function runAsRequest($command, $args){ $application = $this->getApplication(); $client = new Client(); + $endpointBase = $application->getEndpoint(); + $params = [ + 'timeout' => 0, + 'json' => [ + 'token' => $application->getAuthToken(), + 'params'=> $args + ] + ]; + + // Skip SSL validation for localhost only as localhost never has a valid cert + if (preg_match('/^https:\/\/localhost\/.*/i', $endpointBase)){ + $params['verify'] = false; + } + $request = $client->createRequest( 'POST', - $application->getEndpoint() . $command, - [ - 'timeout' => 0, - 'json' => [ - 'token' => $application->getAuthToken(), - 'params'=> $args - ] - ] + $endpointBase . $command, + $params ); $response = $client->send($request);