file_get_contents(): 无法定位证书 CN [英] file_get_contents(): Unable to locate certificate CN

查看:47
本文介绍了file_get_contents(): 无法定位证书 CN的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有两个域(都是 https):一个作为主域 https://dev.project.com/ 另一个用于图像 https://dev-images.project.com/.首页加载图像很好,但我遇到了file_get_contents 的问题.

We are having two domains ( both https ): one as main domain https://dev.project.com/ and the other for images https://dev-images.project.com/. The frontpage loads the images just fine, but I'm having this problem with file_get_contents.

ErrorException in Collection.php line 228:
file_get_contents(): Unable to locate certificate CN
in Collection.php line 228
at HandleExceptions->handleError('2', 'file_get_contents(): Unable to locate certificate CN', '')
at file_get_contents('https://dev-images.project.com/images/12012_resized.jpg') in Collection.php line 228

文件本身存在并在浏览器中签入时打开.我检查了这个解决方案,但所有的测试都是正面:

The file itself exists and opens when checked in browser. I checked this solution, but all the tests are positive:

openssl: yes
http wrapper: yes
https wrapper: yes
wrappers: array (size=12) ...

php.ini

extension=php_openssl.dll
allow_url_fopen = On

证书在本地生成并在php.ini中设置

The certificate is locally generated and set in php.ini

curl.cainfo = "D:\wamp64\cacert.pem"

我的开发站在带有 PHP 5.6 的 Window10 上有 wamp64 服务器.网站基于 Laravel5.

My dev station has wamp64 server on Window10 with Php 5.6. Site is based on Laravel5.

推荐答案

尝试像这样将路径传递给您的 cafile.

Try to passing the path to your cafile like this.

$opts=array(
    "ssl"=>array(
        "cafile" => "D:\\wamp64\\cacert.pem",
        "verify_peer"=> true,
        "verify_peer_name"=> true
    )
);

file_get_contents($url,false,stream_context_create($opts));

如果这仅在您的本地服务器上失败,请检查您是否在本地服务器的 cacert.pem 中添加了本地创建的 SSL 证书,并且它不包含错误或额外的行.

edit: if this fails only in your local server, check if you have you added your locally created SSL cert in cacert.pem in your local server and that it contains no errors or extra lines.

这篇关于file_get_contents(): 无法定位证书 CN的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆