Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getUrlContent should verify the SSL certificate #7330

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/private/apphelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
7 changes: 6 additions & 1 deletion lib/private/util.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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', '') != '') {
Expand All @@ -1049,6 +1051,9 @@ public static function getUrlContent($url) {
$contextArray = array(
'http' => array(
'timeout' => 10
),
'ssl' => array(
'verify_peer' => $verifyCert
)
);
}
Expand Down
3 changes: 2 additions & 1 deletion lib/public/ihelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}