From ca692ef60d23b8c1313828bbf71a1349b4f9c3fe Mon Sep 17 00:00:00 2001 From: ghost Date: Tue, 28 Dec 2021 22:32:23 +0200 Subject: [PATCH] add ssl mode with self-signed certificate support --- src/bootstrap.php | 3 ++- src/config-default.php | 3 ++- src/system/curl.php | 7 +++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/bootstrap.php b/src/bootstrap.php index d01cada..2d1d67c 100644 --- a/src/bootstrap.php +++ b/src/bootstrap.php @@ -19,7 +19,8 @@ $_twister = new Twister( TWISTER_HOST, TWISTER_PORT, TWISTER_USER, - TWISTER_PASSWORD + TWISTER_PASSWORD, + TWISTER_SSL ) ); diff --git a/src/config-default.php b/src/config-default.php index 50258c7..0487228 100644 --- a/src/config-default.php +++ b/src/config-default.php @@ -17,6 +17,7 @@ define('DB_PASSWORD', ''); // TWISTER define('TWISTER_HOST', 'localhost'); define('TWISTER_PORT', 28332); +define('TWISTER_SSL', true); define('TWISTER_PROTOCOL', ''); define('TWISTER_USER', ''); -define('TWISTER_PASSWORD', ''); \ No newline at end of file +define('TWISTER_PASSWORD', ''); diff --git a/src/system/curl.php b/src/system/curl.php index 8d94c8e..85ea194 100644 --- a/src/system/curl.php +++ b/src/system/curl.php @@ -6,16 +6,19 @@ class Curl { private $_protocol; private $_host; private $_port; + private $_ssl; public function __construct(string $protocol, string $host, int $port, string $username, - string $password) { + string $password, + bool $ssl) { $this->_protocol = $protocol; $this->_host = $host; $this->_port = $port; + $this->_ssl = $ssl; $this->_curl = curl_init(); @@ -52,7 +55,7 @@ class Curl { curl_setopt($this->_curl, CURLOPT_CONNECTTIMEOUT, $timeout); curl_setopt($this->_curl, CURLOPT_TIMEOUT, $timeout); - if ($method == 'https') { + if ($this->_ssl) { curl_setopt($this->_curl, CURLOPT_SSL_VERIFYPEER, $validate); curl_setopt($this->_curl, CURLOPT_SSL_VERIFYHOST, $validate); }