Search code examples
phpmacoshttpsopensslalfred

Local PHP failing to load HTTPS urls


I have an Alfred workflow that needs to pull image files from remote servers. Up until recently, this was working fine until I suddenly started getting errors from imagecreatefromgif():

SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

And:

Failed to enable crypto.

It happens with any https URL, so it's not the encryption on the remote server. After a ton of Googling, I ran the script in this answer and the wrappers look good:

openssl: yes
http wrapper: yes
https wrapper: yes
wrappers: array (
    0 => 'https',
    1 => 'ftps',
    2 => 'compress.zlib',
    3 => 'compress.bzip2',
    4 => 'php',
    5 => 'file',
    6 => 'glob',
    7 => 'data',
    8 => 'http',
    9 => 'ftp',
    10 => 'phar',
    11 => 'zip',
)

PHP configuration is kind of outside my wheelhouse, so I'm a bit lost. I have no idea why my mac's PHP install has lost the ability to read files over https.

Anyone have any insights?


Solution

  • Finally figured it out - after searching a searching I stumbled upon this insanely helpful post: https://akrabat.com/ssl-certificate-verification-on-php-5-6/

    Followed those steps and everything now works perfectly.