roach-php / core

The complete web scraping toolkit for PHP.

Home Page:https://roach-php.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Self signed certificate

ntaylor-86 opened this issue · comments

Description
Hello, I'm sure this is possible I just couldn't find a reference to it in the docs.

How do you tell Roach to accept self signed certificates?

Cheers.

You can configure options on the underlying Guzzle request using $request->addOption(string $name, mixed $value).

So you could write a request middleware that sets the verify option on each outgoing request and then use that as a downloader middleware in you spider.

use RoachPHP\Downloader\Middleware\RequestMiddlewareInterface;
use RoachPHP\Http\Request;
use RoachPHP\Support\Configurable;

final class WithoutCertificateValidation implements RequestMiddlewareInterface
{
    use Configurable;

    public function handleRequest(Request $request): Request
    {
        // Completely disable SSL certificate verification.
        return $request->addOption('verify', false);
    }
}