1
0

Workaround PHP < 5.6 bug, not verifying certs, stopping Request2

See http://board.s9y.org/viewtopic.php?f=10&t=20773 and #399
This commit is contained in:
onli
2016-06-22 19:40:36 +02:00
parent b39bf70345
commit d973e99933
9 changed files with 89 additions and 31 deletions

View File

@ -125,7 +125,12 @@ class ONYX_RSS
require_once S9Y_PEAR_PATH . 'HTTP/Request2.php';
serendipity_request_start();
$req = new HTTP_Request2($uri, HTTP_Request2::METHOD_GET, array('follow_redirects' => true, 'max_redirects' => 5));
$options = array('follow_redirects' => true, 'max_redirects' => 5);
if (version_compare(PHP_VERSION, '5.6.0', '<')) {
// On earlier PHP versions, the certificate validation fails. We deactivate it on them to restore the functionality we had with HTTP/Request1
$options['ssl_verify_peer'] = false;
}
$req = new HTTP_Request2($uri, HTTP_Request2::METHOD_GET, $options);
try {
$res = $req->send();
@ -348,7 +353,12 @@ class ONYX_RSS
{
require_once S9Y_PEAR_PATH . 'HTTP/Request2.php';
serendipity_request_start();
$req = new HTTP_Request2($uri);
$options = array();
if (version_compare(PHP_VERSION, '5.6.0', '<')) {
// On earlier PHP versions, the certificate validation fails. We deactivate it on them to restore the functionality we had with HTTP/Request1
$options['ssl_verify_peer'] = false;
}
$req = new HTTP_Request2($uri, HTTP_Request2::METHOD_GET, $options);
try {
$response = $req->send();