Question

Working on a localhost version of my https live site. Using the WP Super Cache plug-in.

Trying to test it [Test Cache] with the feature with my live sites certificate I get the error

Fetching http://localhost/mysite/ to prime cache: FAILED Errors: : cURL error 60: SSL certificate problem: unable to get local issuer certificate

Trying it with a self-signed certificate OpenSSL and cacert.pem in a httpd-ssl.conf and php.ini modified localhost WAMP configuration I get the error:

Fetching http://localhost/mysite/ to prime cache: FAILED Errors: : cURL error 60: SSL certificate problem: self signed certificate

I even tried disabling SSL verification off in the WordPress init

add_action( 'init', 'sslfalse' );

function sslfalse() {
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
}

And I still get the same error regardless.

Anyone know of a possible solution to getting WP Super Cache (or any caching plug-in) to work with HTTPS on localhost?

Was it helpful?

Solution

Follow on to comment is too long so done as answer:

As I understand it your test site works as HTTPS unless WPSC is activated?

  1. Another (quick to test) hunch:

    Under WPSC "Advanced" settings: check on "Simple" then check the "Late Init" (and/or "HTTP Headers") boxes - save settings. N.B. if you deactivate WPSC these settings are lost and will require re-checking.

    You mentioned trying another caching plugin - if so try one that executes later without mod_rewrites. I wrote the Country Caching plugin extensions for both WPSC and Comet cache. So I'd suggest trying Comet Cache; it is not as sophisticated as WPSC, but as a plugin author, I found it to be better designed.

    N.B. If you are testing e.g. an ecommerce site where what is not cached is often more important than what is - then both live and test should use the same caching plugin and ideally with the same caching method settings.

  2. Add contents of yourInstalled.cert to WP's certification authority (CA) list

    No personal knowledge; but a post about a similar WPSC problem on nginx advises adding the text of your self signed cert to "/wp-includes/certificates/ca-bundle.crt". It will have to be re-applied after every WP update.

  3. Pay a web host for a test environment on a separate server.

    It might be possible to create a LetsEncrypt cert for use on a "localhost" but this would be far from straight forward.

    If you are running a commercial site then I would have thought it would be worth paying ($5? p.m.) to a web host with choice of PHP version, MySQL & cpanel with free LetsEncrypt SSL cert install. Buy a new domain, or CNAME a sub domain for use in this environment; obviously WP will have to be configured for this new domain - but your environment can be a (near) exact match to live. Prevent indexing via robots.txt, noindex, and maybe basic authentication. Disable site when not testing. When not in use switch to maintenance mode and disable/redirect away via conf/htaccess.

"might have to disable https on my local environment, but I'd prefer to keep everything congruent"

If site serves same content under both HTTP and HTTPS, then limiting test to HTTP again should not be a problem. If caching requirements are straight forward e.g. you do not have to worry about what is not being cached on an e-commerce site or you are not caching by visitor country; then disabling caching on test is another option.

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top