File_get_contents(): SSL operation failed with code 1

What issue or error are you experiencing?

SSL is working on a local site. It is trusted. The site loads over https.
I have created an API endpoint that outputs json from a db query.
The endpoint works. I can see the json output if I put the URL in my browser.
When I use get_file_contents() with the endpoint, I get this error:

file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:0A000086:SSL routines::certificate verify failed

I have seen many posts about this topic, but none have answers. I have asked Google to no avail. My apologies for opening this particular worm can again.

I deleted the cert files and recreated. No change.

I work with custom API endpoints regularly. I uploaded my work to our staging site and the script works. It definitely has to do with my local environment. I can fake it by just copying the json to a string, but I am stubborn and really don’t want to do that. It seems it should be possible to make this work.

Thanks in advance for any insight!


What steps can be taken to replicate the issue? Feel free to include screenshots, videos, etc

I don’t think it is possible to replicate the issue outside of my environment without duplicating my install. I uploaded my work to a staging site and it works just fine.


System Details

Windows 11
Chrome Version 119.0.6045.124 (Official Build) (64-bit)
Local version 8.1.0+6514
PHP 8.2.10 (I was using 8.1.23, but switched to see if the problem would go away)
nginx
MySQL 8.0.16
Wordpress 6.4.1

  • Local Version:
    8.1.0+6514

  • Operating System (OS) and OS version:
    Windows 11


Local Logs

Attach your Local Logs here (Help Doc - Retrieving Local’s Log)

[16-Nov-2023 02:51:03 UTC] PHP Warning: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages:
error:0A000086:SSL routines::certificate verify failed in C:\Users\galdr\Local Sites\lwa\app\public\wp-content\plugins\lwa-stores\includes\functions-tasks-store-edit.php on line 6
[16-Nov-2023 02:51:03 UTC] PHP Warning: file_get_contents(): Failed to enable crypto in C:\Users\galdr\Local Sites\lwa\app\public\wp-content\plugins\lwa-stores\includes\functions-tasks-store-edit.php on line 6
[16-Nov-2023 02:51:03 UTC] PHP Warning: file_get_contents(https://lwa.local/wp-json/lwa-store-tasks/v1/clients): Failed to open stream: operation failed in C:\Users\galdr\Local Sites\lwa\app\public\wp-content\plugins\lwa-stores\includes\functions-tasks-store-edit.php on line 6


Security Reminder
Local does a pretty good job of scrubbing private info from the logs and the errors it produces, however there’s always the possibility that something private can come through. Because these are public forums, always review the screenshots you are sharing to make sure there isn’t private info like passwords being displayed.

Update: A site that was not having SSL/cURL issues is also having issues now since I updated Local yesterday. I didn’t think to check that site.

Update 2: One of my sites had not yet had the SSL “trusted.” This problem existed on it. Then I marked the SSL “trusted,” now the cURL issue is gone. So, if I can figure out how to “re-trust” the certs on my other sites, perhaps they will work again, too.

Update 3: Reissuing and re-trusting certificate had no impact. Upgrading the working site to the latest WP made it stop working. Now looking into the WP version as an issue. I know a recent update caused cURL issues but I thought it had been fixed.

Final update: reinstalling Wordpress 6.3.2 removed the cURL issue.

1 Like

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.

Thank you for coming to the Forums @tgranzo and sharing your workflow and solutions here! Hopefully your details will help others who run into similar issues. :green_heart:

1 Like