add ssl mode with self-signed certificate support

This commit is contained in:
ghost 2021-12-28 22:32:23 +02:00
parent c7252261c0
commit ca692ef60d
3 changed files with 9 additions and 4 deletions

View File

@ -19,7 +19,8 @@ $_twister = new Twister(
TWISTER_HOST,
TWISTER_PORT,
TWISTER_USER,
TWISTER_PASSWORD
TWISTER_PASSWORD,
TWISTER_SSL
)
);

View File

@ -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', '');
define('TWISTER_PASSWORD', '');

View File

@ -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);
}