litespeedtech / lscache_wp

LiteSpeed Cache for WordPress
http://wordpress.org/plugins/litespeed-cache/
GNU General Public License v3.0
209 stars 111 forks source link

Using WP-CLI Integration on a Development Environment with Self-signed Certificate #233

Open bugfloyd opened 4 years ago

bugfloyd commented 4 years ago

I'm setting up a staging server which is a cloned version of a production website and I wrote some shell script to automate the synchronization process and renaming the URLs etc.

The production domain is: www.example.com The staging server domain is: www.example.test Staging server uses native OpenLitespeed webserver and it's IP address is 192.168.1.10. OLS is listening on this IP and port 443 for a secure connection and uses a self-signed certificate. (generated via OpenSSL) I've also added these lines to /etc/hosts on the staging server to resolve the .test URLs locally:

192.168.1.10 example.test
192.168.1.10 www.example.test

I'm trying to use WP-CLI in my script to purge Litespeed cache on the staging server, after a successful sync. I use this command to purge all cache:

wp litespeed-purge all --path=/path/to/wp/files

However I get this error:

Error: Failed to get url 'https://www.example.test/wp-admin/admin-ajax.php': cURL error 60: Peer's certificate issuer has been marked as not trusted by the user..

It seems that litespeed uses cURL to send a request to the site to purge the cache and we know it's possible to use cURL with self-signed certificates using --insecure option however I think it's not possible to pass this option directly to wp litespeed-purge.

Has anyone encountered this problem before? Can someone give me a point to figure it out?

J-Rey commented 3 years ago

Have you tried using a default config file for cURL with your current setup?

I normally would copy the production certs to my staging server (so would validate with other things besides LSCWP) & add the domains to my laptop's hosts file (not just on the staging server) though.

mitchellkrogza commented 2 years ago

I have the latest wp cli when I try run anything I get

Error: 'litespeed-option' is not a registered wp command. See 'wp help' for available commands.

Seems to be very little documentation that I can find to clear this up

J-Rey commented 2 years ago

@mitchellkrogza I would check the WP-CLI documentation on how to specify current WP path since it sounds like it can't find a WP installation that also has LSCWP.

Now I just tested with latest WP-CLI & LSCWP and found that there are some new options missing in the LSCWP WP-CLI documentation though so feel free to use wp help litespeed-option in the meantime till its updated.