configuredco / haulable

Create standalone PHP CLI applications with PHP Micro CLI
MIT License
163 stars 3 forks source link

Compiled SSL Error #8

Open vmitchell85 opened 1 month ago

vmitchell85 commented 1 month ago

I have a Laravel Zero project that I've used Haulable for. The commands run, which is great, but I've gotten a error with my HTTP call.

Error Message:

cURL error 60: SSL certificate problem: unable to get local issuer certificate (see https://curl.haxx.se/libc
  url/c/libcurl-errors.html) for https://__REDACTED__

Code:

use Illuminate\Support\Facades\Http;
//...
Http::withHeader('Apikey', 'REDACTED')
    ->withHeader('User-Agent', 'REDACTED')
    ->get($url);

To test I updated my HTTP call to use withoutVerifying() and withOptions(["verify"=>false]), recompiled, re-hauled (is that a word?), and it then runs without the SSL error.

Working Code:

use Illuminate\Support\Facades\Http;
//...
Http::withoutVerifying()
    ->withOptions(["verify"=>false])
    ->withHeader('Apikey', 'REDACTED')
    ->withHeader('User-Agent', 'REDACTED')
    ->get($url);

I would prefer to keep the SSL verification if possible.

Thanks in advance for your awesome package and your help.

joecampo commented 1 month ago

Hey @vmitchell85! I have a couple ideas, let me give this a try.

I'm about to publish some updates for this project (been tied up with family/work).

joecampo commented 3 weeks ago

@vmitchell85 I think I figured this out. The issue is that once compiled, it can't find the path to the system CA bundle.

The easiest way I found to solve it is to use https://github.com/composer/ca-bundle. Composer was nice enough to extract this to its own package.

Then in your app, you can use it like so:

use Composer\CaBundle\CaBundle;

Http::withOptions(['verify' => CaBundle::getSystemCaRootBundlePath()])
    ->get('https://api.ipify.org/');
vmitchell85 commented 3 weeks ago

Thanks @joecampo ... I'll give it a shot!