1

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.

enter image description here

sotirov
  • 3,169
Steve
  • 11
  • 1
    Can you do me a favor and run 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
  • This is the result... # curl https://ipinfo.io/ip curl: (35) error:0A000152:SSL routines::unsafe legacy renegotiation disabled – Steve Jun 28 '23 at 16:42
  • Is there some type of proxy in line between your system and the Internet? Unsafe renegotiation disabled suggests something's eating your connection in an insecure way, which may also explain your certificate chain issues if your proxy uses its own CA / certificate to show 'valid certs' for every domain. – Thomas Ward Jun 28 '23 at 16:46
  • There is no proxy I am aware of. – Steve Jun 28 '23 at 16:48

1 Answers1

0

Try reinstalling the ca-certificates package.

sudo apt install --reinstall ca-certificates

Reference: What is the use/purpose of the ca-certificates package?

sotirov
  • 3,169