elementor / elementor/wp2static
Error 500 when generating site on LocalWP. Also PHP error: cURL error 60: SSL certificate problem: self signed certificate
- Dominant language
- PHP
- Stars
- 1.5k
- Forks
- 294
- PR merge metrics
- No merged PRs in 30d
Description
Likely issue: **Environmental**
**Describe the bug**
I am running wp2static locally using [Local WP](https://localwp.com/).
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](https://community.localwp.com/t/ssl-certificate-problem-on-windows/22666/12). 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](https://lando.dev/) 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](https://localwp.com/) 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
Contributor guide
Assessment
This issue has not been assessed yet.