Skip to content
Snippets Groups Projects
Commit 7600c42d authored by specky_rum's avatar specky_rum Committed by Chris Leppanen
Browse files

Issue #1062178 by mansspams, MegaChriz, gmclelland, specky_rum, Dave Reid |...

Issue #1062178 by mansspams, MegaChriz, gmclelland, specky_rum, Dave Reid | iccle: Added configuration option to allow invalid/unverified or (self certified) SSL certificates.
parent 3e2bbd11
No related branches found
No related tags found
No related merge requests found
......@@ -26,6 +26,14 @@ class FeedsHTTPFetcherResult extends FeedsFetcherResult {
*/
protected $timeout;
/**
*
* Whether to ignore SSL validation errors.
*
* @var bool
*/
protected $acceptInvalidCert;
/**
* Constructor.
*/
......@@ -39,7 +47,7 @@ class FeedsHTTPFetcherResult extends FeedsFetcherResult {
public function getRaw() {
if (!isset($this->raw)) {
feeds_include_library('http_request.inc', 'http_request');
$result = http_request_get($this->url, NULL, NULL, NULL, $this->timeout);
$result = http_request_get($this->url, NULL, NULL, $this->acceptInvalidCert, $this->timeout);
if (!in_array($result->code, array(200, 201, 202, 203, 204, 205, 206))) {
throw new Exception(t('Download of @url failed with code !code.', array('@url' => $this->url, '!code' => $result->code)));
}
......@@ -56,6 +64,17 @@ class FeedsHTTPFetcherResult extends FeedsFetcherResult {
public function setTimeout($timeout) {
$this->timeout = $timeout;
}
/**
* Sets the accept invalid certificates option.
*
* @param bool $accept_invalid_cert
* Whether to accept invalid certificates.
*/
public function setAcceptInvalidCert($accept_invalid_cert) {
$this->acceptInvalidCert = (bool) $accept_invalid_cert;
}
}
/**
......@@ -74,6 +93,7 @@ class FeedsHTTPFetcher extends FeedsFetcher {
$fetcher_result = new FeedsHTTPFetcherResult($source_config['source']);
// When request_timeout is empty, the global value is used.
$fetcher_result->setTimeout($this->config['request_timeout']);
$fetcher_result->setAcceptInvalidCert($this->config['accept_invalid_cert']);
return $fetcher_result;
}
......@@ -123,6 +143,7 @@ class FeedsHTTPFetcher extends FeedsFetcher {
'designated_hub' => '',
'request_timeout' => NULL,
'auto_scheme' => 'http',
'accept_invalid_cert' => FALSE,
);
}
......@@ -176,6 +197,12 @@ class FeedsHTTPFetcher extends FeedsFetcher {
'#maxlength' => 3,
'#size'=> 30,
);
$form['advanced']['accept_invalid_cert'] = array(
'#type' => 'checkbox',
'#title' => t('Accept invalid SSL certificates'),
'#description' => t('<strong>IMPORTANT:</strong> This setting will force cURL to completely ignore all SSL errors. This is a <strong>major security risk</strong> and should only be used during development.'),
'#default_value' => $this->config['accept_invalid_cert'],
);
return $form;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment