cloudflare / cloudflare/cloudflare-php
Changing guzzle adapter options
- Dominant language
- PHP
- Stars
- 674
- Forks
- 268
- PR merge metrics
- No merged PRs in 30d
Description
I've come across this issue while testing your api. Guzzle throws an exception complaining there's no ca file on a windows box. For those OS' without a default known ca file, [see guzzle verify](https://guzzle.readthedocs.io/en/stable/request-options.html#verify), it is not possible to set a default ca-file without altering the php.ini or PATH environment. To solve this issue,
**Either**
//to set options to the guzzle client
public getClient() { return $this->client; }
**Or**
public function __construct(Auth $auth, string $baseURI = null, $guzzleConfig = [])
{
if ($baseURI === null) {
$baseURI = 'https://api.cloudflare.com/client/v4/';
}
$headers = $auth->getHeaders();
$config = [
'base_uri' => $baseURI,
'headers' => $headers,
'Accept' => 'application/json'
] + $guzzleConfig;
$this->client = new Client($config);
}
**Or**
public function __construct(Auth $auth, string $baseURI = null, $caFile = false)
{
if ($baseURI === null) {
$baseURI = 'https://api.cloudflare.com/client/v4/';
}
$headers = $auth->getHeaders();
$config = [
'base_uri' => $baseURI,
'headers' => $headers,
'Accept' => 'application/json'
];
if ($caFile !== false) $config['verify'] = $caFile;
$this->client = new Client($config);
}
can be done.
Contributor guide
Assessment
This issue has not been assessed yet.