file_get_contents() reports ssl certificate verify failed error handling

Today, the server (centos) uses yum update to update the file_get_contents() of php and reports an error. The php version is the wrong content of 5.6:

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

The literal meaning should be that the key file verification failed. Find the key file location of openssl on the first page and use:

var_dump(openssl_get_cert_locations());

Return content:

array ( 'default_cert_file' => '/etc/pki/xxx/cert.pem', 'default_cert_file_env' => 'SSL_CERT_FILE', 'default_cert_dir' => '/etc/pki/xxx/certs', 'default_cert_dir_env' => 'SSL_CERT_DIR', 'default_private_dir' => '/etc/pki/xxx/private', 'default_default_cert_area' => '/etc/pki/xxx', 'ini_cafile' => '/etc/pki/xxx/cert.pem', 'ini_capath' => '', )

The default_cert_file is the location of the key file and then add it after php.ini:

openssl.cafile=/etc/pki/xxx/cert.pem

After restarting PHP, there should be no error!

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324436636&siteId=291194637