Skip to content
This repository has been archived by the owner on Oct 30, 2023. It is now read-only.

Commit

Permalink
Ad support for downloading CA via proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
dmzoneill committed May 3, 2018
1 parent 004016c commit 53e048a
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions php-binance-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -2103,15 +2103,24 @@ private function downloadCurlCaBundle()
$output_filename = getcwd() . "/ca.pem";

$host = "https://curl.haxx.se/ca/cacert.pem";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $host);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$result = curl_exec($ch);
curl_close($ch);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $host);
curl_setopt($curl, CURLOPT_VERBOSE, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);

// proxy settings
if (is_array($this->proxyConf)) {
curl_setopt($curl, CURLOPT_PROXY, $this->getProxyUriString());
if (isset($this->proxyConf['user']) && isset($this->proxyConf['pass'])) {
curl_setopt($curl, CURLOPT_PROXYUSERPWD, $this->proxyConf['user'] . ':' . $this->proxyConf['pass']);
}
}

$result = curl_exec($curl);
curl_close($curl);

$fp = fopen($output_filename, 'w');
fwrite($fp, $result);
Expand Down

0 comments on commit 53e048a

Please sign in to comment.