summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Auth/Yadis/HTTPFetcher.php22
-rw-r--r--Auth/Yadis/ParanoidHTTPFetcher.php14
-rw-r--r--Auth/Yadis/PlainHTTPFetcher.php13
3 files changed, 49 insertions, 0 deletions
diff --git a/Auth/Yadis/HTTPFetcher.php b/Auth/Yadis/HTTPFetcher.php
index 95f27df..4b46140 100644
--- a/Auth/Yadis/HTTPFetcher.php
+++ b/Auth/Yadis/HTTPFetcher.php
@@ -48,6 +48,28 @@ class Auth_Yadis_HTTPFetcher {
}
/**
+ * Does this fetcher implementation (and runtime) support fetching
+ * HTTPS URLs? May inspect the runtime environment.
+ *
+ * @return bool $support True if this fetcher supports HTTPS
+ * fetching; false if not.
+ */
+ function supportsSSL()
+ {
+ trigger_error("not implemented", E_USER_ERROR);
+ }
+
+ /**
+ * Is this an https URL?
+ *
+ * @access private
+ */
+ function isHTTPS($url)
+ {
+ return (bool)preg_match('/^https:\/\//i', $url);
+ }
+
+ /**
* Is this an http or https URL?
*
* @access private
diff --git a/Auth/Yadis/ParanoidHTTPFetcher.php b/Auth/Yadis/ParanoidHTTPFetcher.php
index b37227c..54797e7 100644
--- a/Auth/Yadis/ParanoidHTTPFetcher.php
+++ b/Auth/Yadis/ParanoidHTTPFetcher.php
@@ -54,8 +54,18 @@ class Auth_Yadis_ParanoidHTTPFetcher extends Auth_Yadis_HTTPFetcher {
return strlen($data);
}
+ function supportsSSL()
+ {
+ $v = curl_version();
+ return in_array('https', $v['protocols']);
+ }
+
function get($url, $extra_headers = null)
{
+ if ($this->isHTTPS($url) && !$this->supportsSSL()) {
+ return null;
+ }
+
$stop = time() + $this->timeout;
$off = $this->timeout;
@@ -130,6 +140,10 @@ class Auth_Yadis_ParanoidHTTPFetcher extends Auth_Yadis_HTTPFetcher {
{
$this->reset();
+ if ($this->isHTTPS($url) && !$this->supportsSSL()) {
+ return null;
+ }
+
if (!$this->allowedURL($url)) {
trigger_error(sprintf("Fetching URL not allowed: %s", $url),
E_USER_WARNING);
diff --git a/Auth/Yadis/PlainHTTPFetcher.php b/Auth/Yadis/PlainHTTPFetcher.php
index 5fac50d..242bf99 100644
--- a/Auth/Yadis/PlainHTTPFetcher.php
+++ b/Auth/Yadis/PlainHTTPFetcher.php
@@ -26,8 +26,17 @@ require_once "Auth/Yadis/HTTPFetcher.php";
* @package OpenID
*/
class Auth_Yadis_PlainHTTPFetcher extends Auth_Yadis_HTTPFetcher {
+ function supportsSSL()
+ {
+ return function_exists('openssl_open');
+ }
+
function get($url, $extra_headers = null)
{
+ if ($this->isHTTPS($url) && !$this->supportsSSL()) {
+ return null;
+ }
+
if (!$this->allowedURL($url)) {
trigger_error("Bad URL scheme in url: " . $url,
E_USER_WARNING);
@@ -137,6 +146,10 @@ class Auth_Yadis_PlainHTTPFetcher extends Auth_Yadis_HTTPFetcher {
function post($url, $body, $extra_headers = null)
{
+ if ($this->isHTTPS($url) && !$this->supportsSSL()) {
+ return null;
+ }
+
if (!$this->allowedURL($url)) {
trigger_error("Bad URL scheme in url: " . $url,
E_USER_WARNING);