New to Ubuntu but have some RHEL experience. On a fresh 22.04 install attempting to pull a file using:
php -r "copy('https://somesite.com/file.txt', 'mylocalfile.txt');"
I get the following error:
PHP Warning: copy(): SSL operation failed with code 1. OpenSSL Error messages:
error:0A0000:SSL routines::certificate verify failed in Command line code on line 1
PHP Warning: copy(): Failed to enable crypto in Command line code on line 1
PHP Warning: copy('https://somesite.com/file.txt', 'mylocalfile.txt');: Failed to open stream: operation failed in Command line code on line 1.
This happens with any site. I tried downloading the server cert and placing it in /etc/ssl/certs/ca-certificates
but no luck. I'm also getting similar errors when trying to do https
file downloads.
I can use wget
with --no-check-certificate
but I need to get it to work without bypassing security. I'm assuming this is an easy fix but being new to Ubuntu is making it more complex than it should be.
curl https://ipinfo.io/ip
and see what the output is and if you receive SSL errors? When running things in PHP, the PHP command line might not properly be importing the proper SSL contexts, so testing via cURL won't hurt but will help test the certificate verification on your system. It sounds like you have a broken certificates install. Seeing the output of cURL or such will give us potentially more info than the PHP warnings. – Thomas Ward Jun 28 '23 at 14:57