file_get_contents 函数证书问题

最近项目中把网站升级https。升级后发现有错误信息,file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages:\nerror:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed

查了相关资料,主要是因为php版本更新,证书这一块处理有变化。
详情参考官方网站信息:http://php.net/manual/en/migration56.openssl.php

解决办法主要有两种:

  1. php.ini中配置证书
  2. file_get_contents添加参数,去掉验证

ps:使用第一种方式测试不成功,使用第二种方式可以。
参考资料:http://www.bigsoft.co.uk/blog/2017/04/29/file-get-contents-ssl-operation-failed-with-code-1-ssl3-get-server-certificate-certificate-verify-failed

猜你喜欢

转载自blog.csdn.net/hu_feng903/article/details/83089363