1
0
mirror of https://github.com/guzzle/guzzle.git synced 2025-02-25 10:33:18 +01:00

Using copied cacert when using phar

This commit is contained in:
Michael Dowling 2013-04-01 10:07:11 -07:00
parent 393a110ec0
commit 9dc8897140

View File

@ -83,14 +83,15 @@ class Client extends AbstractHasDispatcher implements ClientInterface
// Allow ssl.certificate_authority config setting to control the certificate authority used by curl
$authority = $this->config->get(self::SSL_CERT_AUTHORITY);
// Set the SSL certificate
if ($authority !== 'system') {
if (substr(__FILE__, 0, 7) == 'phar://') {
$this->preparePharCacert();
}
if ($authority === null) {
$authority = true;
}
if ($authority === true && substr(__FILE__, 0, 7) == 'phar://') {
$authority = $this->preparePharCacert();
}
$this->setSslVerification($authority);
}
@ -485,14 +486,14 @@ class Client extends AbstractHasDispatcher implements ClientInterface
{
$certFile = sys_get_temp_dir() . '/cacert.pem';
if (file_exists($certFile)) {
return;
if (!copy('phar://guzzle.phar/src/Guzzle/Http/Resources/cacert.pem', $certFile)) {
throw new RuntimeException(
'Could not copy phar://guzzle.phar/src/Guzzle/Http/Resources/cacert.pem to '
. $certFile
);
}
}
if (!copy('phar://guzzle.phar/src/Guzzle/Http/Resources/cacert.pem', $certFile)) {
throw new RuntimeException(
'Could not copy phar://guzzle.phar/src/Guzzle/Http/Resources/cacert.pem to '
. $certFile
);
}
return $certFile;
}
}