Problem
When fetching data from a website using Guzzle, I got this error:
| |
Opening the same URL in Chrome worked fine. Checking the SSL certificate showed it was issued by COMODO RSA Organization Validation Secure Server CA. After some research, I found the Root CA certificate was missing on Linux.
First Attempt
I downloaded the certificate from the Comodo website and placed it under /etc/ssl/certs. Still got the same error.
Final Solution
Specify the certificate path directly in GuzzleHttp:
| |
How to Do It in Laravel
If all HTTP requests need this certificate, bind it in AppServiceProvider:
| |
If only a specific service needs it, use contextual binding:
| |
This way only the Client injected into GitHubService will include the certificate — other usages remain unaffected.
References
- GuzzleHttp Official Docs: Request Options — Full documentation for the verify option
- Laravel Official Docs: Contextual Binding — How to use contextual binding in the service container
- Comodo Root Certificate Download — Official COMODO RSA root certificate download page
