diff --git a/lib/private/apphelper.php b/lib/private/apphelper.php index bd02f3aabfa6..1e300ebb35c6 100644 --- a/lib/private/apphelper.php +++ b/lib/private/apphelper.php @@ -17,9 +17,10 @@ class AppHelper implements \OCP\IHelper { * Gets the content of an URL by using CURL or a fallback if it is not * installed * @param string $url the url that should be fetched + * @param bool $verifyCert Whether the SSL certificate should get verified (defaults to yes) * @return string the content of the webpage */ - public function getUrlContent($url) { - return \OC_Util::getUrlContent($url); + public function getUrlContent($url, $verifyCert = true) { + return \OC_Util::getUrlContent($url, $verifyCert); } } diff --git a/lib/private/util.php b/lib/private/util.php index d3b682daa5c2..1c1829377d38 100755 --- a/lib/private/util.php +++ b/lib/private/util.php @@ -1010,11 +1010,12 @@ public static function secureRNGAvailable() { /** * @Brief Get file content via curl. * @param string $url Url to get content + * @param bool $verifyCert Whether the SSL certificate should get verified (defaults to yes) * @return string of the response or false on error * This function get the content of a page via curl, if curl is enabled. * If not, file_get_contents is used. */ - public static function getUrlContent($url) { + public static function getUrlContent($url, $verifyCert = true) { if (function_exists('curl_init')) { $curl = curl_init(); @@ -1024,6 +1025,7 @@ public static function getUrlContent($url) { curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); curl_setopt($curl, CURLOPT_MAXREDIRS, 10); + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, $verifyCert); curl_setopt($curl, CURLOPT_USERAGENT, "ownCloud Server Crawler"); if(OC_Config::getValue('proxy', '') != '') { @@ -1049,6 +1051,9 @@ public static function getUrlContent($url) { $contextArray = array( 'http' => array( 'timeout' => 10 + ), + 'ssl' => array( + 'verify_peer' => $verifyCert ) ); } diff --git a/lib/public/ihelper.php b/lib/public/ihelper.php index c0723b8edc7c..17b851e12823 100644 --- a/lib/public/ihelper.php +++ b/lib/public/ihelper.php @@ -38,7 +38,8 @@ interface IHelper { * Gets the content of an URL by using CURL or a fallback if it is not * installed * @param string $url the url that should be fetched + * @param bool $verifyCert Whether the SSL certificate should get verified (defaults to yes) * @return string the content of the webpage */ - public function getUrlContent($url); + public function getUrlContent($url, $verifyCert); }