file_get_contents(): SSL operation failed with code 1, Failed to enable crypto

前端 未结 16 1790
情歌与酒
情歌与酒 2020-11-22 04:31

I’ve been trying to access this particular REST service from a PHP page I’ve created on our server. I narrowed the problem down to these two lines. So my PHP page looks li

16条回答
  •  忘了有多久
    2020-11-22 04:56

    Another thing to try is to re-install ca-certificates as detailed here.

    # yum reinstall ca-certificates
    ...
    # update-ca-trust force-enable 
    # update-ca-trust extract
    

    And another thing to try is to explicitly allow the one site's certificate in question as described here (especially if the one site is your own server and you already have the .pem in reach).

    # cp /your/site.pem /etc/pki/ca-trust/source/anchors/
    # update-ca-trust extract
    

    I was running into this exact SO error after upgrading to PHP 5.6 on CentOS 6 trying to access the server itself which has a cheapsslsecurity certificate which maybe it needed to be updated, but instead I installed a letsencrypt certificate and with these two steps above it did the trick. I don't know why the second step was necessary.


    Useful Commands

    View openssl version:

    # openssl version
    OpenSSL 1.0.1e-fips 11 Feb 2013
    

    View PHP cli ssl current settings:

    # php -i | grep ssl
    openssl
    Openssl default config => /etc/pki/tls/openssl.cnf
    openssl.cafile => no value => no value
    openssl.capath => no value => no value
    

提交回复
热议问题