Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: HTTP Requests: SSL certificate problem: unable to get local issuer certificate #20

Closed
StanBarrows opened this issue Jul 21, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@StanBarrows
Copy link

StanBarrows commented Jul 21, 2023

What happened?

I've wrote a small scheduler where I would like to send a GET request to an external API. Sending requests from my NativePHP application throws an SSL Certificate Problem.

$response = Http::timeout(3)->get('https://www.codebar.ch');

2023-07-21 02:53:28] local.ERROR: cURL error 60: SSL certificate problem: unable to get local issuer certificate (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://www.codebar.ch {"exception":"[object] (GuzzleHttp\\Exception\\RequestException(code: 0): cURL error 60: SSL certificate problem: unable to get local issuer certificate (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://www.codebar.ch at /Users/sebastian/Projects/native/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php:211)
[stacktrace]
#0 /Users/sebastian/Projects/native/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php(158): GuzzleHttp\\Handler\\CurlFactory::createRejection(Object(GuzzleHttp\\Handler\\EasyHandle), Array)
#1 /Users/sebastian/Projects/native/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php(110): GuzzleHttp\\Handler\\CurlFactory::finishError(Object(GuzzleHttp\\Handler\\CurlHandler), Object(GuzzleHttp\\Handler\\EasyHandle), Object(GuzzleHttp\\Handler\\CurlFactory))
#2 /Users/sebastian/Projects/native/vendor/guzzlehttp/guzzle/src/Handler/CurlHandler.php(47): GuzzleHttp\\Handler\\CurlFactory::finish(Object(GuzzleHttp\\Handler\\CurlHandler), Object(GuzzleHttp\\Handler\\EasyHandle), Object(GuzzleHttp\\Handler\\CurlFactory))
#3 /Users/sebastian/Projects/native/vendor/guzzlehttp/guzzle/src/Handler/Proxy.php(28): GuzzleHttp\\Handler\\CurlHandler->__invoke(Object(GuzzleHttp\\Psr7\\Request), Array)
#4 /Users/sebastian/Projects/native/vendor/guzzlehttp/guzzle/src/Handler/Proxy.php(48): GuzzleHttp\\Handler\\Proxy::GuzzleHttp\\Handler\\{closure}(Object(GuzzleHttp\\Psr7\\Request), Array)
#5 /Users/sebastian/Projects/native/vendor/laravel/framework/src/Illuminate/Http/Client/PendingRequest.php(1225): GuzzleHttp\\Handler\\Proxy::GuzzleHttp\\Handler\\{closure}(Object(GuzzleHttp\\Psr7\\Request), Array)
#6 /Users/sebastian/Projects/native/vendor/laravel/framework/src/Illuminate/Http/Client/PendingRequest.php(1191): Illuminate\\Http\\Client\\PendingRequest->Illuminate\\Http\\Client\\{closure}(Object(GuzzleHttp\\Psr7\\Request), Array)
#7 /Users/sebastian/Projects/native/vendor/laravel/framework/src/Illuminate/Http/Client/PendingRequest.php(1177): Illuminate\\Http\\Client\\PendingRequest->Illuminate\\Http\\Client\\{closure}(Object(GuzzleHttp\\Psr7\\Request), Array)
#8 /Users/sebastian/Projects/native/vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php(35): Illuminate\\Http\\Client\\PendingRequest->Illuminate\\Http\\Client\\{closure}(Object(GuzzleHttp\\Psr7\\Request), Array)
#9 /Users/sebastian/Projects/native/vendor/guzzlehttp/guzzle/src/Middleware.php(38): GuzzleHttp\\PrepareBodyMiddleware->__invoke(Object(GuzzleHttp\\Psr7\\Request), Array)
#10 /Users/sebastian/Projects/native/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php(71): GuzzleHttp\\Middleware::GuzzleHttp\\{closure}(Object(GuzzleHttp\\Psr7\\Request), Array)
#11 /Users/sebastian/Projects/native/vendor/guzzlehttp/guzzle/src/Middleware.php(63): GuzzleHttp\\RedirectMiddleware->__invoke(Object(GuzzleHttp\\Psr7\\Request), Array)
#12 /Users/sebastian/Projects/native/vendor/guzzlehttp/guzzle/src/HandlerStack.php(75): GuzzleHttp\\Middleware::GuzzleHttp\\{closure}(Object(GuzzleHttp\\Psr7\\Request), Array)
#13 /Users/sebastian/Projects/native/vendor/guzzlehttp/guzzle/src/Client.php(333): GuzzleHttp\\HandlerStack->__invoke(Object(GuzzleHttp\\Psr7\\Request), Array)
#14 /Users/sebastian/Projects/native/vendor/guzzlehttp/guzzle/src/Client.php(169): GuzzleHttp\\Client->transfer(Object(GuzzleHttp\\Psr7\\Request), Array)
#15 /Users/sebastian/Projects/native/vendor/guzzlehttp/guzzle/src/Client.php(189): GuzzleHttp\\Client->requestAsync('GET', Object(GuzzleHttp\\Psr7\\Uri), Array)
#16 /Users/sebastian/Projects/native/vendor/laravel/framework/src/Illuminate/Http/Client/PendingRequest.php(1039): GuzzleHttp\\Client->request('GET', 'https://www.cod...', Array)
#17 /Users/sebastian/Projects/native/vendor/laravel/framework/src/Illuminate/Http/Client/PendingRequest.php(892): Illuminate\\Http\\Client\\PendingRequest->sendRequest('GET', 'https://www.cod...', Array)
#18 /Users/sebastian/Projects/native/vendor/laravel/framework/src/Illuminate/Support/helpers.php(248): Illuminate\\Http\\Client\\PendingRequest->Illuminate\\Http\\Client\\{closure}(1)
#19 /Users/sebastian/Projects/native/vendor/laravel/framework/src/Illuminate/Http/Client/PendingRequest.php(932): retry(0, Object(Closure), 100, Object(Closure))
#20 /Users/sebastian/Projects/native/vendor/laravel/framework/src/Illuminate/Http/Client/PendingRequest.php(769): Illuminate\\Http\\Client\\PendingRequest->send('GET', 'https://www.cod...', Array)
#21 /Users/sebastian/Projects/native/app/Console/Commands/ProjectStatusUpdateCommand.php(49): Illuminate\\Http\\Client\\PendingRequest->get('https://www.cod...')
#22 /Users/sebastian/Projects/native/vendor/laravel/framework/src/Illuminate/Database/Concerns/BuildsQueries.php(98): App\\Console\\Commands\\ProjectStatusUpdateCommand->App\\Console\\Commands\\{closure}(Object(App\\Models\\Project), 0)
#23 /Users/sebastian/Projects/native/vendor/laravel/framework/src/Illuminate/Database/Concerns/BuildsQueries.php(53): Illuminate\\Database\\Eloquent\\Builder->Illuminate\\Database\\Concerns\\{closure}(Object(Illuminate\\Database\\Eloquent\\Collection), 1)
#24 /Users/sebastian/Projects/native/vendor/laravel/framework/src/Illuminate/Database/Concerns/BuildsQueries.php(102): Illuminate\\Database\\Eloquent\\Builder->chunk(1000, Object(Closure))
#25 /Users/sebastian/Projects/native/app/Console/Commands/ProjectStatusUpdateCommand.php(57): Illuminate\\Database\\Eloquent\\Builder->each(Object(Closure))
#26 /Users/sebastian/Projects/native/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): App\\Console\\Commands\\ProjectStatusUpdateCommand->handle()
#27 /Users/sebastian/Projects/native/vendor/laravel/framework/src/Illuminate/Container/Util.php(41): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
#28 /Users/sebastian/Projects/native/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\\Container\\Util::unwrapIfClosure(Object(Closure))
#29 /Users/sebastian/Projects/native/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): Illuminate\\Container\\BoundMethod::callBoundMethod(Object(Illuminate\\Foundation\\Application), Array, Object(Closure))
#30 /Users/sebastian/Projects/native/vendor/laravel/framework/src/Illuminate/Container/Container.php(662): Illuminate\\Container\\BoundMethod::call(Object(Illuminate\\Foundation\\Application), Array, Array, NULL)
#31 /Users/sebastian/Projects/native/vendor/laravel/framework/src/Illuminate/Console/Command.php(208): Illuminate\\Container\\Container->call(Array)
#32 /Users/sebastian/Projects/native/vendor/symfony/console/Command/Command.php(326): Illuminate\\Console\\Command->execute(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle))
#33 /Users/sebastian/Projects/native/vendor/laravel/framework/src/Illuminate/Console/Command.php(178): Symfony\\Component\\Console\\Command\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle))
#34 /Users/sebastian/Projects/native/vendor/symfony/console/Application.php(1081): Illuminate\\Console\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#35 /Users/sebastian/Projects/native/vendor/symfony/console/Application.php(320): Symfony\\Component\\Console\\Application->doRunCommand(Object(App\\Console\\Commands\\ProjectStatusUpdateCommand), Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#36 /Users/sebastian/Projects/native/vendor/symfony/console/Application.php(174): Symfony\\Component\\Console\\Application->doRun(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#37 /Users/sebastian/Projects/native/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(201): Symfony\\Component\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#38 /Users/sebastian/Projects/native/artisan(37): Illuminate\\Foundation\\Console\\Kernel->handle(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#39 {main}
"} 

How to reproduce the bug

Run php artisan native:serve

Send a HTTP GET request within a scheduler

$response = Http::timeout(3)->get('https://www.codebar.ch');

Package Version

0.1

PHP Version

8.2

Laravel Version

10.*

Which operating systems does with happen with?

macOS

Notes

Workaround enable withoutVerifying the request.

Http::withoutVerifying()->timeout(3)->get($project->url);

@StanBarrows StanBarrows added the bug Something isn't working label Jul 21, 2023
@StanBarrows
Copy link
Author

@mpociot
Copy link
Member

mpociot commented Jul 29, 2023

Just tried it again, this is now working 👍

@mpociot mpociot closed this as completed Jul 29, 2023
@marcusmyers
Copy link

Still getting this error with version 0.4.0 on my app. What was your solution @mpociot?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants