From 212c7f5b7c963525aa7a957f89a5619368fc8331 Mon Sep 17 00:00:00 2001 From: "j.faassen" Date: Sat, 6 Aug 2016 15:39:38 +0200 Subject: [PATCH] Support cacert verification in ProviderClient --- src/Provider/ProviderClient.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Provider/ProviderClient.php b/src/Provider/ProviderClient.php index 61f8c04..0fd72d6 100644 --- a/src/Provider/ProviderClient.php +++ b/src/Provider/ProviderClient.php @@ -21,6 +21,12 @@ public function __construct($username = null, $password = null) $this->username = $username; $this->password = $password; $this->httpClient = new GuzzleClient(); + + + $this->verify = __DIR__ . '/../../cacert.pem'; + if (!file_exists($this->verify)) { + throw new RuntimeException('cacert.pem not found: ' . $this->verify); + } } @@ -75,7 +81,10 @@ private function getResourceDataV1(Resource $resource, Source $source) //echo "REQUESTING: " . $fullUrl . "\n"; $res = $this->httpClient->get( $url, - [ 'headers' => $headers ] + [ + 'headers' => $headers, + 'verify' => $this->verify + ] ); if ($res->getStatusCode() == 200) { $res = (string)$res->getBody(); @@ -103,7 +112,8 @@ private function getResourceDataV3(Source $source) $res = $this->httpClient->get( $url, [ - 'headers' => [] + 'headers' => [], + 'verify' => $this->verify ] ); if ($res->getStatusCode() == 200) {