SSL error SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

后端 未结 9 1168
走了就别回头了
走了就别回头了 2020-12-01 07:03

After upgrading to PHP 5.6 I get an error when trying to connect to a server via fsockopen()..

The certificate on the server (host) is self-signed

9条回答
  •  借酒劲吻你
    2020-12-01 07:41

    In my case, I was on CentOS 7 and my php installation was pointing to a certificate that was being generated through update-ca-trust. The symlink was /etc/pki/tls/cert.pem pointing to /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem. This was just a test server and I wanted my self signed cert to work properly. So in my case...

    # My root ca-trust folder was here. I coped the .crt file to this location
    # and renamed it to a .pem
    /etc/pki/ca-trust/source/anchors/self-signed-cert.pem
    
    # Then run this command and it will regenerate the certs for you and
    # include your self signed cert file.
    update-ca-trust
    

    Then some of my api calls started working as my cert was now trusted. Also if your ca-trust gets updated through yum or something, this will rebuild your root certificates and still include your self signed cert. Run man update-ca-trust for more info on what to do and how to do it. :)

提交回复
热议问题