sjelfull / Craft-CacheWarmer

Warm up your cache with a single request.
38 stars 4 forks source link

Issue with SSL and Guzzle #3

Open hisnameisjimmy opened 6 years ago

hisnameisjimmy commented 6 years ago

Running into an issue with Guzzle where it wants the SSL certificate info. Looked into it, it appears you need to specify a verify if you have an SSL: http://guzzle.readthedocs.io/en/stable/request-options.html#verify-option

If we could expose this through the GUI, so that you could append a path instead of modifying the plugin code, I think it would be good to avoid this issue.

sjelfull commented 6 years ago

Isn't this a problem with the target host not having a valid certificate?

hisnameisjimmy commented 6 years ago

It's more a problem with Guzzle not being able to find it in normal locations, I believe.

I'm using Forge by Laravel, and their location for the file is: /etc/nginx/ssl/domain.com/#####/cert.crt

I modified your code to reflect the correct path with a setDefaultOption that points to the correct bundle file:

            // Create client
            $client = new Guzzle();
            $client->setDefaultOption('verify', '/etc/nginx/ssl/domain.com/#####/bundle.crt');
            // Create a new pool and send off requests, 20 at a time
            $transferStrategy = new BatchRequestTransfer($this->settings->parallelRequests);
            $divisorStrategy = $transferStrategy;
            $batch = new Batch($transferStrategy, $divisorStrategy);

This fixed the issue. I'm gonna fork your repo and create a settings input that allows you to specify this in the GUI. I'll then drop you a pull request.