Fix bug with curl ssl verify peer

This commit is contained in:
Anton Medvedev 2017-08-29 12:14:52 +07:00
parent 386b91ba46
commit 818dbdb7f2
4 changed files with 36 additions and 6 deletions

View File

@ -1,8 +1,15 @@
# Changelog
## master
[v6.0.1...master](https://github.com/deployphp/deployer/compare/v6.0.1...master)
[v6.0.2...master](https://github.com/deployphp/deployer/compare/v6.0.2...master)
🍰
## v6.0.2
[v6.0.1...v6.0.2](https://github.com/deployphp/deployer/compare/v6.0.1...v6.0.2)
### Fixed
- Fixed bug with curl ssh check in _Httpie_ util
## v6.0.1
[v6.0.0...v6.0.1](https://github.com/deployphp/deployer/compare/v6.0.0...v6.0.1)

View File

@ -17,3 +17,10 @@ ControlPersist causes stderr to be left open until the master connection times o
* https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=714526
* https://bugzilla.mindrot.org/show_bug.cgi?id=1988
## cURL 7.29.0
Certificate verification fails with multiple https urls.
* https://bugzilla.redhat.com/show_bug.cgi?id=1241172

View File

@ -13,6 +13,7 @@ class Httpie
private $url = '';
private $headers = [];
private $body = '';
private $curlopts = [];
public function __construct()
{
@ -76,6 +77,13 @@ class Httpie
return $http;
}
public function setopt($key, $value)
{
$http = clone $this;
$http->curlopts[$key] = $value;
return $http;
}
public function send()
{
$ch = curl_init($this->url);
@ -87,6 +95,9 @@ class Httpie
curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
foreach ($this->curlopts as $key => $value) {
curl_setopt($ch, $key, $value);
}
$result = curl_exec($ch);
curl_close($ch);
return $result;

View File

@ -14,9 +14,6 @@ class Reporter
{
const ENDPOINT = 'https://deployer.org/api/stats';
/**
* @param array $stats
*/
public static function report(array $stats)
{
$pid = null;
@ -28,7 +25,7 @@ class Reporter
if (is_null($pid) || $pid === -1) {
// Fork fails or there is no `pcntl` extension.
try {
Httpie::post(self::ENDPOINT)->body($stats)->send();
self::send($stats);
} catch (\Throwable $e) {
// pass
}
@ -36,7 +33,7 @@ class Reporter
// Child process.
posix_setsid();
try {
Httpie::post(self::ENDPOINT)->body($stats)->send();
self::send($stats);
} catch (\Throwable $e) {
// pass
}
@ -44,4 +41,12 @@ class Reporter
exit(0);
}
}
private static function send(array $stats)
{
Httpie::post(self::ENDPOINT)
->body($stats)
->setopt(CURLOPT_SSL_VERIFYPEER, false)
->send();
}
}