Reputation: 3546
This should be an easy thing to do. I can find plenty of references to how to do it in Guzzle 3, but they don't work in Guzzle 5.
What I am doing so far:
$this->client = new GuzzleClient(['defaults' => [
'verify' => 'false'
]]);
When I send a request though I get this error:
RequestException in RequestException.php line 51:
SSL CA bundle not found: false
I cannot find any useful reference to this error on google. If I could get access to the curl options then I could try something like the solution suggested here (which is for Guzzle 3, hence why it doesn't work): http://inchoo.net/dev-talk/symfony2-guzzle-ssl-self-signed-certificate/, the relevant section of which is:
$req->getCurlOptions()->set(CURLOPT_SSL_VERIFYHOST, false);
$req->getCurlOptions()->set(CURLOPT_SSL_VERIFYPEER, false);
Upvotes: 92
Views: 162313
Reputation: 719
Turning off SSL is unsafe, but can be okay for local debugging.
I turning it off in Guzzle source code, in guzzlehttp\guzzle\src\Client.php
:
private function configureDefaults(array $config): void
{
$defaults = [
'allow_redirects' => RedirectMiddleware::$defaultSettings,
'http_errors' => true,
'decode_content' => true,
'verify' => FALSE, // default is true, but use FALSE to turn off SSL on local PC
'cookies' => false,
'idn_conversion' => false,
];
Upvotes: -1
Reputation: 57
In laravel http client you can use withoutVerifying()
method to disable ssl verification:
Http::withoutVerifying()->...
Upvotes: 0
Reputation: 323
Easier way to disable SSL veritication on Laravel HTTP Client (Laravel 7 onwards).
Http::withOptions(['verify' => false])->get($url)->json();
Docs: https://laravel.com/docs/7.x/http-client#guzzle-options
Upvotes: 0
Reputation: 6351
For someone using Laravel HTTP Client below solution worked for me
use GuzzleHttp\Client;
use Illuminate\Support\Facades\Http;
Http::baseUrl('http://example.com')
->setClient(new Client(['verify' => false]))
->get('user/lits.htm',[
'page_no' => '5',
'per_page' => '25',
])
->json();
Upvotes: 0
Reputation: 527
you can use in the new laravel client version with
$http = new Client(['verify' => false]);
Upvotes: 13
Reputation: 1266
You should use
$this->client = new GuzzleClient(['defaults' => [
'verify' => false
]]);
i.e. a Boolean false, not the string 'false'
The documentation is here: https://docs.guzzlephp.org/en/5.3/clients.html#verify
Note: a few people have given other answers that apply to Guzzle 6+. They're good answers if you are using those versions (but the original question was explicitly about Guzzle 5).
Upvotes: 104
Reputation: 2607
The actual version is the correct one:
$this->client = new GuzzleClient(['verify' => false ]);
At 2018, this does not work:
$this->client = new GuzzleClient(['defaults' => [
'verify' => false
]]);
Upvotes: 60
Reputation: 669
Try with updated version that works:
$this->client = new GuzzleClient(['base_uri' => 'https://api.example.com/', 'verify' => false ]);
or a more simple version:
$this->client = new GuzzleClient(['verify' => false ]);
Tested with version 6.2-dev.
Upvotes: 66