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

Error 500 when generating site on LocalWP. Also PHP error: cURL error 60: SSL certificate problem: self signed certificate #870

Open
BenJackGill opened this issue Jun 14, 2022 · 2 comments
Labels

Comments

@BenJackGill
Copy link

BenJackGill commented Jun 14, 2022

Likely issue: Environmental

Describe the bug
I am running wp2static locally using Local WP.

When clicking the "Generate static site" button it returns this error in the browser:

Error code 500 returned from server.
Please check your sever's error logs or try increasing your max_execution_time limit in PHP if this consistently fails after the same duration.
More information of the error may be logged in your browser's console.

My current max_execution_time limit is 12000 so that is not the problem. Also the browser console only says Failed to load resource: the server responded with a status of 500 () so that is not very helpful.

But the PHP logs have this interesting stack trace:

[14-Jun-2022 21:34:26 UTC] PHP Stack trace:
[14-Jun-2022 21:34:26 UTC] PHP   1. {main}() /Users/BenJackGill/Local Sites/asiaaspect/app/public/wp-admin/admin-ajax.php:0
[14-Jun-2022 21:34:26 UTC] PHP   2. do_action() /Users/BenJackGill/Local Sites/asiaaspect/app/public/wp-admin/admin-ajax.php:187
[14-Jun-2022 21:34:26 UTC] PHP   3. WP_Hook->do_action() /Users/BenJackGill/Local Sites/asiaaspect/app/public/wp-includes/plugin.php:476
[14-Jun-2022 21:34:26 UTC] PHP   4. WP_Hook->apply_filters() /Users/BenJackGill/Local Sites/asiaaspect/app/public/wp-includes/class-wp-hook.php:331
[14-Jun-2022 21:34:26 UTC] PHP   5. WP2Static\Controller::wp2staticRun() /Users/BenJackGill/Local Sites/asiaaspect/app/public/wp-includes/class-wp-hook.php:305
[14-Jun-2022 21:34:26 UTC] PHP   6. WP2Static\Controller::wp2staticHeadless() /Users/BenJackGill/Local Sites/asiaaspect/app/public/wp-content/plugins/wp2static/src/Controller.php:745
[14-Jun-2022 21:34:26 UTC] PHP   7. WP2Static\URLDetector::detectURLs() /Users/BenJackGill/Local Sites/asiaaspect/app/public/wp-content/plugins/wp2static/src/Controller.php:633
[14-Jun-2022 21:34:26 UTC] PHP   8. WP2Static\DetectCustomPostTypeURLs::detect() /Users/BenJackGill/Local Sites/asiaaspect/app/public/wp-content/plugins/wp2static/src/URLDetector.php:60
[14-Jun-2022 21:34:26 UTC] PHP   9. get_post_permalink() /Users/BenJackGill/Local Sites/asiaaspect/app/public/wp-content/plugins/wp2static/src/DetectCustomPostTypeURLs.php:25
[14-Jun-2022 21:34:27 UTC] PHP Fatal error:  Uncaught WP2StaticGuzzleHttp\Exception\RequestException: cURL error 60: SSL certificate problem: self signed certificate (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://asiaaspect.local//sitemap.xml in /Users/BenJackGill/Local Sites/asiaaspect/app/public/wp-content/plugins/wp2static/vendor/leonstafford/wp2staticguzzle/src/Handler/CurlFactory.php:211
Stack trace:
#0 /Users/BenJackGill/Local Sites/asiaaspect/app/public/wp-content/plugins/wp2static/vendor/leonstafford/wp2staticguzzle/src/Handler/CurlFactory.php(158): WP2StaticGuzzleHttp\Handler\CurlFactory::createRejection(Object(WP2StaticGuzzleHttp\Handler\EasyHandle), Array)
#1 /Users/BenJackGill/Local Sites/asiaaspect/app/public/wp-content/plugins/wp2static/vendor/leonstafford/wp2staticguzzle/src/Handler/CurlFactory.php(110): WP2StaticGuzzleHttp\Handler\CurlFactory::finishError(Object(WP2StaticGuzzleHttp\Handler\CurlHandler), Object(WP2StaticGuzzleHttp\Handler\EasyHandle), Object(WP2StaticGuzzleHttp\Handler\CurlFactory))
#2 /Users/BenJack in /Users/BenJackGill/Local Sites/asiaaspect/app/public/wp-content/plugins/wp2static/src/DetectSitemapsURLs.php on line 127

The interesting part is this line showing a cURL error 60 for WP2Static Guzzle:

PHP Fatal error:  Uncaught WP2StaticGuzzleHttp\Exception\RequestException: cURL error 60: SSL certificate problem: self signed certificate (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://asiaaspect.local//sitemap.xml in /Users/BenJackGill/Local Sites/asiaaspect/app/public/wp-content/plugins/wp2static/vendor/leonstafford/wp2staticguzzle/src/Handler/CurlFactory.php:211

I did some further digging and found a similar issue here on the Local WP support forums. The developers of Local WP says the issue is because the plugin is using Guzzle and crafting it's own HTTP requests without using the built-in WP functions. If the requests were refactored the plugin could benefit from the fallbacks and guarding that WP comes with.

I have also tested this issue by using the site with Lando and it does not have the same problem. So think the issue resides with how the enviroment (i.e. Local WP) handles cert issues. But if wp2static used the built-in WP functions for the request it wouldn't have the same problems.

To Reproduce
Steps to reproduce the behaviour:

  1. Download Local WP and create a new site with wp2static and wp2static Netlify plugins installed
  2. Click on WP2static > Run > Generate Static Site
  3. See error

Expected behaviour
No error and site is uploaded to Netlify

Environment (please complete the following information):

  • Hosting OS: MacOs Monterey version 12.4
  • Web server setup: Local WP version 6.4.0 / PHP 7.4.1 / MySQL 8.0.16 / WordPress Version 6.0
  • Hosting company: Local computer
@BenJackGill BenJackGill changed the title Error 500 when generating site on LocalWP - PHP error: cURL error 60: SSL certificate problem: self signed certificate Error 500 when generating site on LocalWP. Also PHP error: cURL error 60: SSL certificate problem: self signed certificate Jun 14, 2022
@BenJackGill
Copy link
Author

I fixed this by downgrading from PHP 7.4.1 to PHP 7.3.5.

It now works with Local WP.

@BenJackGill
Copy link
Author

BenJackGill commented Nov 23, 2022

Update: This issue is still ongoing.

I have just tested PHP 7.4.3 and it looks like that version is also working on LocalWP.

Other PHP versions above this (8.0.22 and 8.1.9) will show debugging errors inside WordPress under the WP2Static > Caches tab. So I would avoid using those versions.

Side note: If you are on a Mac you also have to accept the LocalWP SSL certificate manually. In LocalWP open up your site and click "Trust" next to SSL. Then on your Mac go to "Keychain Access" and you will see a certificate for a matching domain name (the domain name of the site you just trusted in LocalWP). It will have a red "X" next to it. Double click that, open the "trust" section, and change "When using this certificate" to "Always Trust". The restart your site in LocalWP. Doing that AND using the correct PHP version as advised above will remove the error.

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

No branches or pull requests

2 participants