From 768f3979e048d5661fdf84fe3e8174f6d1147df3 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Tue, 4 Nov 2014 16:44:42 +0100 Subject: [PATCH 1/2] Check for cert bundle existence before using it --- apps/files_sharing/lib/external/storage.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/apps/files_sharing/lib/external/storage.php b/apps/files_sharing/lib/external/storage.php index 92d8f92b380..2da0022028f 100644 --- a/apps/files_sharing/lib/external/storage.php +++ b/apps/files_sharing/lib/external/storage.php @@ -198,12 +198,22 @@ class Storage extends DAV implements ISharedStorage { curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); - curl_setopt($ch, CURLOPT_CAINFO, $this->certificateManager->getCertificateBundle()); + $path = $this->certificateManager->getCertificateBundle(); + if (is_readable($path)) { + curl_setopt($ch, CURLOPT_CAINFO, $path); + } $result = curl_exec($ch); $status = curl_getinfo($ch, CURLINFO_HTTP_CODE); + $errorMessage = null; + if ($status === 0) { + $errorMessage = curl_error($ch); + } curl_close($ch); + if ($errorMessage) { + throw new \Exception($errorMessage); + } switch ($status) { case 401: From ee6d8c9d589c95a12fab5d1a1bcfdd3c6ad8f4c0 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Tue, 4 Nov 2014 17:37:15 +0100 Subject: [PATCH 2/2] Store curl error message directly --- apps/files_sharing/lib/external/storage.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/apps/files_sharing/lib/external/storage.php b/apps/files_sharing/lib/external/storage.php index 2da0022028f..3f1d631a35f 100644 --- a/apps/files_sharing/lib/external/storage.php +++ b/apps/files_sharing/lib/external/storage.php @@ -206,12 +206,9 @@ class Storage extends DAV implements ISharedStorage { $result = curl_exec($ch); $status = curl_getinfo($ch, CURLINFO_HTTP_CODE); - $errorMessage = null; - if ($status === 0) { - $errorMessage = curl_error($ch); - } + $errorMessage = curl_error($ch); curl_close($ch); - if ($errorMessage) { + if (!empty($errorMessage)) { throw new \Exception($errorMessage); }