Skip to content

Commit

Permalink
Option to use system CA Bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
dmzoneill committed Jul 14, 2018
1 parent cd1a9da commit 07e7b8c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
8 changes: 8 additions & 0 deletions README.md
Expand Up @@ -66,6 +66,14 @@ while(true) {
}
```

#### Security - Ca Bunldes
If you don't know what a CA bundle is, no action is required. If you do know and you don't like our auto upate feature.
You can disable the downloading of the CA Bundle
```php
$api = new Binance\API( "somefile.json" );
$api->caOverride = true;
```

#### Get latest price of a symbol
```php
$ticker = $api->prices();
Expand Down
14 changes: 13 additions & 1 deletion examples/candles.php
Expand Up @@ -8,5 +8,17 @@

// Get Kline/candlestick data for a symbol
// Periods: 1m,3m,5m,15m,30m,1h,2h,4h,6h,8h,12h,1d,3d,1w,1M
$ticks = $api->candlesticks("BNBBTC", "5m");
$ticks = $api->candlesticks("EOSBTC", "1m");
print_r($ticks);
//$ticks = $api->candlesticks("BNBBTC", "15m");
//print_r($ticks);
//$ticks = $api->candlesticks("BNBBTC", "8h");
//print_r($ticks);
//$ticks = $api->candlesticks("BNBBTC", "2h");
//print_r($ticks);
//$ticks = $api->candlesticks("BNBBTC", "1d");
//print_r($ticks);
//$ticks = $api->candlesticks("BNBBTC", "30m");
//print_r($ticks);
//$ticks = $api->candlesticks("BNBBTC", "1M");
//print_r($ticks);
13 changes: 9 additions & 4 deletions php-binance-api.php
Expand Up @@ -42,6 +42,7 @@ class API
"timeOffset" => 0,
]; // /< Additional connection options
protected $proxyConf = null; // /< Used for story the proxy configuration
protected $caOverride = false; // /< set this if you donnot wish to use CA bundle auto download feature
protected $transfered = 0; // /< This stores the amount of bytes transfered
protected $requestCount = 0; // /< This stores the amount of API requests
private $httpDebug = false; // /< If you enable this, curl will output debugging information
Expand Down Expand Up @@ -829,8 +830,10 @@ private function httpRequest(string $url, string $method = "GET", array $params
throw new \Exception("Sorry cURL is not installed!");
}

if (file_exists(getcwd() . '/ca.pem') === false) {
$this->downloadCurlCaBundle();
if ($this->caOverride === false) {
if (file_exists(getcwd() . '/ca.pem') === false) {
$this->downloadCurlCaBundle();
}
}

$curl = curl_init();
Expand Down Expand Up @@ -907,8 +910,10 @@ private function httpRequest(string $url, string $method = "GET", array $params
curl_setopt($curl, constant($key), $value);
}

if (file_exists(getcwd() . '/ca.pem')) {
curl_setopt($curl, CURLOPT_CAINFO, getcwd() . '/ca.pem');
if ($this->caOverride === false) {
if (file_exists(getcwd() . '/ca.pem') === false) {
$this->downloadCurlCaBundle();
}
}

$output = curl_exec($curl);
Expand Down

0 comments on commit 07e7b8c

Please sign in to comment.