SSL error SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

后端 未结 9 1148
走了就别回头了
走了就别回头了 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:48

    Have you tried using the stream_context_set_option() method ?

    $context = stream_context_create();
    $result = stream_context_set_option($context, 'ssl', 'local_cert', '/etc/ssl/certs/cacert.pem');
    $fp = fsockopen($host, $port, $errno, $errstr, 20, $context);
    

    In addition, try file_get_contents() for the pem file, to make sure you have permissions to access it, and make sure the host name matches the certificate.

提交回复
热议问题