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

Self signed certificate #158

Closed
ntaylor-86 opened this issue Sep 15, 2023 · 2 comments
Closed

Self signed certificate #158

ntaylor-86 opened this issue Sep 15, 2023 · 2 comments
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@ntaylor-86
Copy link

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.

@ntaylor-86 ntaylor-86 added the documentation Improvements or additions to documentation label Sep 15, 2023
@ksassnowski
Copy link
Contributor

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);
    }
}

@ntaylor-86
Copy link
Author

Thanks @ksassnowski 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants