From 79cf16385ca842cccde19857b5cf7bfa4c70212f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Raoult?= Date: Mon, 9 Jan 2023 17:21:40 +0100 Subject: [PATCH 1/2] Add SSL Cert / SSL Cert Password support --- src/JsonRPC/Client.php | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/JsonRPC/Client.php b/src/JsonRPC/Client.php index d1fe88b..534d586 100644 --- a/src/JsonRPC/Client.php +++ b/src/JsonRPC/Client.php @@ -117,6 +117,22 @@ class Client */ public $ssl_verify_peer = true; + /** + * SSL certificate file + * + * @access public + * @var string + */ + public $ssl_cert_path = null; + + /** + * SSL certificate file password + * + * @access public + * @var string + */ + public $ssl_cert_pass = null; + /** * Constructor * @@ -408,9 +424,11 @@ private function getContext(array $payload) 'content' => json_encode($payload), 'ignore_errors' => true, ), - "ssl" => array( - "verify_peer" => $this->ssl_verify_peer, - "verify_peer_name" => $this->ssl_verify_peer, + 'ssl' => array( + 'verify_peer' => $this->ssl_verify_peer, + 'verify_peer_name' => $this->ssl_verify_peer, + 'local_cert' => $this->ssl_cert_path, + 'passphrase' => $this->ssl_cert_pass ) )); } From 89cad19a9c75ee961868ec926a2bdd55c2f5c868 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Raoult?= Date: Mon, 9 Jan 2023 17:21:48 +0100 Subject: [PATCH 2/2] Close stream --- src/JsonRPC/Client.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/JsonRPC/Client.php b/src/JsonRPC/Client.php index 534d586..041a601 100644 --- a/src/JsonRPC/Client.php +++ b/src/JsonRPC/Client.php @@ -380,6 +380,8 @@ private function doRequest(array $payload) $response = json_decode(stream_get_contents($stream), true); + @fclose($stream); + if ($this->debug) { error_log('==> Request: '.PHP_EOL.json_encode($payload, JSON_PRETTY_PRINT)); error_log('==> Response: '.PHP_EOL.json_encode($response, JSON_PRETTY_PRINT));