Browse Source

add ssl mode with self-signed certificate support

main
ghost 3 years ago
parent
commit
ca692ef60d
  1. 3
      src/bootstrap.php
  2. 3
      src/config-default.php
  3. 7
      src/system/curl.php

3
src/bootstrap.php

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

3
src/config-default.php

@ -17,6 +17,7 @@ define('DB_PASSWORD', '');
// TWISTER // TWISTER
define('TWISTER_HOST', 'localhost'); define('TWISTER_HOST', 'localhost');
define('TWISTER_PORT', 28332); define('TWISTER_PORT', 28332);
define('TWISTER_SSL', true);
define('TWISTER_PROTOCOL', ''); define('TWISTER_PROTOCOL', '');
define('TWISTER_USER', ''); define('TWISTER_USER', '');
define('TWISTER_PASSWORD', ''); define('TWISTER_PASSWORD', '');

7
src/system/curl.php

@ -6,16 +6,19 @@ class Curl {
private $_protocol; private $_protocol;
private $_host; private $_host;
private $_port; private $_port;
private $_ssl;
public function __construct(string $protocol, public function __construct(string $protocol,
string $host, string $host,
int $port, int $port,
string $username, string $username,
string $password) { string $password,
bool $ssl) {
$this->_protocol = $protocol; $this->_protocol = $protocol;
$this->_host = $host; $this->_host = $host;
$this->_port = $port; $this->_port = $port;
$this->_ssl = $ssl;
$this->_curl = curl_init(); $this->_curl = curl_init();
@ -52,7 +55,7 @@ class Curl {
curl_setopt($this->_curl, CURLOPT_CONNECTTIMEOUT, $timeout); curl_setopt($this->_curl, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($this->_curl, CURLOPT_TIMEOUT, $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_VERIFYPEER, $validate);
curl_setopt($this->_curl, CURLOPT_SSL_VERIFYHOST, $validate); curl_setopt($this->_curl, CURLOPT_SSL_VERIFYHOST, $validate);
} }

Loading…
Cancel
Save