简体   繁体   English

php SSL3_GET_SERVER_CERTIFICATE:证书验证失败

[英]php SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

I'm running PHP Version 5.6 as part of XAMPP in MacOSx El Capitan and having error on few https sites. 我在MacOSx El Capitan中运行PHP版本5.6作为XAMPP的一部分,并且在几个https站点上出错。 eg: https://www.google.com/ 例如: https://www.google.com/https://www.google.com/

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

But no SSL error returned on these sites: 但是这些网站上没有返回SSL错误:

  1. GitHub GitHub上
  2. Composer 作曲家
  3. PayPal TLS Test PayPal TLS测试

Please find the list first what i've tried so far but nothing works. 请先找到我迄今为止尝试过的清单,但没有任何效果。

Tried Google first: 首先尝试谷歌:

  1. SSL error SSL3_GET_SERVER_CERTIFICATE:certificate verify failed SSL错误SSL3_GET_SERVER_CERTIFICATE:证书验证失败
  2. PHP - SSL certificate error: unable to get local issuer certificate PHP - SSL证书错误:无法获得本地颁发者证书
  3. HTTPS and SSL3_GET_SERVER_CERTIFICATE:certificate verify failed, CA is OK HTTPS和SSL3_GET_SERVER_CERTIFICATE:证书验证失败,CA正常

Manual 手册

1. Updated cert.pem file 1.更新了cert.pem文件

php -r 'print_r(openssl_get_cert_locations());'

and result was. 结果是。

Array
(
    [default_cert_file] => /Applications/XAMPP/xamppfiles/share/openssl/cert.pem
    [default_cert_file_env] => SSL_CERT_FILE
    [default_cert_dir] => /Applications/XAMPP/xamppfiles/share/openssl/certs
    [default_cert_dir_env] => SSL_CERT_DIR
    [default_private_dir] => /Applications/XAMPP/xamppfiles/share/openssl/private
    [default_default_cert_area] => /Applications/XAMPP/xamppfiles/share/openssl
    [ini_cafile] => /Applications/XAMPP/xamppfiles/share/openssl/cert.pem
    [ini_capath] =>
)

Saved this file cacert.pem in /Applications/XAMPP/xamppfiles/share/openssl/cert.pem /Applications/XAMPP/xamppfiles/share/openssl/cert.pem保存此文件cacert.pem

Updated php.ini with following 更新了php.ini以下内容

openssl.cafile = /Applications/XAMPP/xamppfiles/share/openssl/cert.pem
curl.cainfo    = /Applications/XAMPP/xamppfiles/share/openssl/cert.pem

Restarted Apache but no succes. 重启Apache但没有成功。 Tried to read pem file (no error returned) 试图读取pem文件(没有返回错误)

echo file_get_contents("/Applications/XAMPP/xamppfiles/share/openssl/cert.pem");

Test Case 测试用例

It works fine on github.com getcomposer.org paypal.com but not on google.com (google.com works as well on my windows system) 它在github.com getcomposer.org paypal.comgithub.com getcomposer.org但在google.comgithub.com不正常(google.com在我的Windows系统上运行良好)

php -r '$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://tlstest.paypal.com/"); var_dump(curl_exec($ch)); var_dump(curl_error($ch));'

Result: PayPal_Connection_OKbool(true) 结果: PayPal_Connection_OKbool(true)

But on google.com 但是在google.com

php -r '$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://www.google.com/"); var_dump(curl_exec($ch)); var_dump(curl_error($ch));'

Result: string(63) "SSL certificate problem: unable to get local issuer certificate" 结果: string(63) "SSL certificate problem: unable to get local issuer certificate"

PS: Disabling peer verification won't be acceptable. PS:禁用同行验证是不可接受的。

In my case, making sure that the correct cert.pem file exists was not sufficient. 在我的例子中,确保存在正确的cert.pem文件是不够的。 You need to also set your time zone in your php.ini to your actual time zone using the date.timezone key (in my case, I set it to America/Los Angeles). 您还需要使用date.timezone键将php.ini中的时区设置为您的实际时区(在我的情况下,我将其设置为America / Los Angeles)。 Otherwise, PHP will default to using UTC and your system clock will appear to be off. 否则,PHP将默认使用UTC,您的系统时钟将显示为关闭。 This solved the issue for me on Mac OS X El Capitan (10.11.2). 这解决了我在Mac OS X El Capitan上的问题(10.11.2)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 SSL错误SSL3_GET_SERVER_CERTIFICATE:证书验证失败 - SSL error SSL3_GET_SERVER_CERTIFICATE:certificate verify failed PHPMailer - SSL3_GET_SERVER_CERTIFICATE:证书验证失败 - PHPMailer - SSL3_GET_SERVER_CERTIFICATE:certificate verify failed Composer 错误:14090086:SSL 例程:SSL3_GET_SERVER_CERTIFICATE:证书验证失败 - Composer error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed 错误信息:error:14090086:SSLroutines:ssl3_get_server_certificate:certificate verify failed - Error message: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed SSL3_GET_SERVER_CERTIFICATE证书在Windows 10 Pro with IIS上验证失败 - SSL3_GET_SERVER_CERTIFICATE certificate verify failed on Windows 10 Pro with IIS mysqli_real_connect()获取SSL3_GET_SERVER_CERTIFICATE:证书验证失败 - mysqli_real_connect() getting SSL3_GET_SERVER_CERTIFICATE:certificate verify failed SSL3_GET_SERVER_CERTIFICATE:证书验证在mac上使用xampp失败 - SSL3_GET_SERVER_CERTIFICATE:certificate verify failed using xampp on mac HTTPS and SSL3_GET_SERVER_CERTIFICATE:certificate verify failed, CA is OK - HTTPS and SSL3_GET_SERVER_CERTIFICATE:certificate verify failed, CA is OK PHPMailer 5.2 OpenSSL 错误消息:错误:14090086:SSL 例程:SSL3_GET_SERVER_CERTIFICATE:证书验证失败 - PHPMailer 5.2 OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed 使用 php 通过 https 加载外部 xml 文件时出错:SSL3_GET_SERVER_CERTIFICATE - Error when loading external xml file with php via https : SSL3_GET_SERVER_CERTIFICATE
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM