diff --git a/lib/BasicIPP.php b/lib/BasicIPP.php index 4b3feb6..8a8188f 100644 --- a/lib/BasicIPP.php +++ b/lib/BasicIPP.php @@ -73,6 +73,8 @@ class BasicIPP public $http_timeout = 30; // timeout at http connection (seconds) 0 => default => 30. public $http_data_timeout = 30; // data reading timeout (milliseconds) 0 => default => 30. public $ssl = false; + public $is_verify_peer = true; + public $is_verify_peer_name = true; public $debug_level = 3; // max 3: almost silent public $alert_on_end_tag; // debugging purpose: echo "END tag OK" if (1 and reads while end tag) public $with_exceptions = 0; // compatibility mode for old scripts @@ -409,11 +411,11 @@ public function setSides($sides = 2) switch ($sides) { - case 1: + case "1": $sides = "one-sided"; break; - case 2: + case "2": $sides = "two-sided-long-edge"; break; @@ -807,6 +809,8 @@ protected function _sendHttp($post_values, $uri) } $http->port = $this->port; $http->timeout = $this->http_timeout; + $http->is_verify_peer = $this->is_verify_peer; + $http->is_verify_peer_name = $this->is_verify_peer_name; $http->data_timeout = $this->http_data_timeout; $http->force_multipart_form_post = false; $http->user = $this->username; diff --git a/lib/http_class.php b/lib/http_class.php index 06bceb9..1c8c893 100644 --- a/lib/http_class.php +++ b/lib/http_class.php @@ -136,6 +136,8 @@ class http_class public $data_timeout = 30; // time waiting for data, milliseconds public $data_chunk_timeout = 1; // time waiting between data chunks, millisecond public $force_multipart_form_post; + public $is_verify_peer = true; + public $is_verify_peer_name = true; public $username; public $password; public $request_headers = array(); @@ -232,7 +234,17 @@ public function Open($arguments) } } } - $this->connection = @fsockopen($transport_type . $url, $port, $errno, $errstr, $this->timeout); + if ($transport_type == 'tls://'){ + $context = stream_context_create([ + 'ssl' => [ + 'verify_peer' => $this->is_verify_peer, + 'verify_peer_name' => $this->is_verify_peer_name + ] + ]); + $this->connection = @stream_socket_client($transport_type . $url.':'.$port, $errno, $errstr, $this->timeout, STREAM_CLIENT_CONNECT, $context); + }else { + $this->connection = @fsockopen($transport_type . $url, $port, $errno, $errstr, $this->timeout); + } $error = sprintf(_('Unable to connect to "%s%s port %s": %s'), $transport_type, $url, $port, $errstr);