Skip to content

HTTP::pool response returned without the PSR response when accessing a URL with an expired SSL cert. #41360

@sfilzek

Description

@sfilzek
  • Laravel Version: v9.3.1
  • PHP Version: 8.0.12
  • Database Driver & Version: N/A

Description:

When using the HTTP::pool to access a site with an expired SSL cert, I was expecting a GuzzleHttp\Exception\RequestException to be returned, but instead we get a Illuminate\Http\Client\Response but it is missing the internal PSR response, so accessing any of the response details fails.

Steps To Reproduce:

use Illuminate\Http\Client\Pool;
use Illuminate\Support\Facades\Http;
	
$responses = Http::pool(fn (Pool $pool) => [
    $pool->get('https://expired.badssl.com')
]);

$responses[0]->status();

I would expect the $response[0] to be a type of GuzzleHttp\Exception\RequestException but we get a valid looking Illuminate\Http\Client\Response

The call to ->status() results in an error because the Illuminate\Http\Client\Response internal PSR response property is null:
Call to a member function getStatusCode() on null in ....

At present my solution to detect this failure is to check for a null return on the response->toPsrResponse() and then check for a non zero in the handlerStats ssl_verify_result, but this is fragile as it depends on using the curl supplied ssl_verify_result.

...

if ($responses[0]->toPsrResponse() === null && $responses[0]->handlerStats()['ssl_verify_result']) {
   // SSL error occurred during request
}

Any help or pointers to more detail would be greatly appreciated!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions