Cakephp CAKAPPP中的SSL错误,扩展名=php\u openssl取消注释

Cakephp CAKAPPP中的SSL错误,扩展名=php\u openssl取消注释,cakephp,ssl,Cakephp,Ssl,我正在使用cakePHP,在使用她/他的facebook登录后,我正在尝试在facebook上获取本地的个人资料图片 保存工作正常,我遇到的唯一问题是SSL错误 Warning (2): file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify fa

我正在使用cakePHP,在使用她/他的facebook登录后,我正在尝试在facebook上获取本地的个人资料图片

保存工作正常,我遇到的唯一问题是SSL错误

Warning (2): file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed [APP\Controller\FacebookCpsController.php, line 98]
Warning (2): file_get_contents() [function.file-get-contents]: Failed to enable crypto [APP\Controller\FacebookCpsController.php, line 98]
Warning (2): file_get_contents(https://graph.facebook.com/10203572402389803/picture) [function.file-get-contents]: failed to open stream: operation failed [APP\Controller\FacebookCpsController.php, line 98]
Warning (2): file_put_contents(/files/user_profile) [function.file-put-contents]: failed to open stream: No such file or directory [APP\Controller\FacebookCpsController.php, line 99]
我的控制器名为FacebookCps

这是我的第98行和第99行:

line 98: $image = file_get_contents('https://graph.facebook.com/'.$uid.'/picture'); 
line 99: file_put_contents('/files/user_profile', $image); 
My extension=php_openssl已在My php.ini(C:/xampp/php/phpini)中取消注释


感谢您的建议/帮助。

@Janelle Ann Lagatuz,错误是,“……例程:SSL3\u获取\u服务器\u证书:证书验证失败…”您应该下载一个证书包。将它放在web服务器上可以访问的某个位置,并授予用户读取文件的权限。然后尝试以下代码:

    $arrContextOptions=array(
    "ssl"=>array(
        "cafile" => "/path/to/bundle/ca-bundle.crt",
        "verify_peer"=> true,
        "verify_peer_name"=> true,
    ),
);
它们也是另一种方法,而不是传递证书,只需将verify_peer和verify_peer_name设置为false,并按如下方式传递它(您可以在此处看到此方法的描述:):



但是请记住,这不是一个好方法,因为您没有通过证书,这会破坏SSL证书,并且是一个安全漏洞

@Janelle Ann Lagatuz,错误是,“…例程:SSL3\u获取\u服务器\u证书:证书验证失败…”您应该下载一个证书包。将它放在web服务器上可以访问的某个位置,并授予用户读取文件的权限。然后尝试以下代码:

    $arrContextOptions=array(
    "ssl"=>array(
        "cafile" => "/path/to/bundle/ca-bundle.crt",
        "verify_peer"=> true,
        "verify_peer_name"=> true,
    ),
);
它们也是另一种方法,而不是传递证书,只需将verify_peer和verify_peer_name设置为false,并按如下方式传递它(您可以在此处看到此方法的描述:):



但是请记住,这不是一个好方法,因为您没有通过证书,这会破坏SSL证书,并且是一个安全漏洞

多谢各位。是的,我有一个证书放在供应商/Facebook/fb\u ca\u chain\u捆绑包中。这张证书可以吗?我也已经安装了它。$arrContextOptions=array(“ssl”=>array(“cafile”=>“/Vendor/Facebook/fb\u ca\u chain\u bundle.crt”,“verify\u peer”=>true,“verify\u peer\u name”=>true,);我尝试了它,但未能加载crt文件,因此现在我使用另一种方法将verify_peer和verify_peer_name设置为false,只要证书有效且脚本可以访问,我认为您做得很好。请注意,对于下载证书捆绑包,请尝试以下操作:您的答案非常有用,我现在可以访问证书并尝试回显文件\u get\u内容,它有一个值,但现在剩余的错误是无法打开流:没有这样的文件或目录,我在文件文件夹下有一个文件夹名user\u profile,为什么它说没有这样的文件目录?您的意思是,在这个参数“cafile”=>“/path/to/bundle/ca bundle.crt”中,它说的是“无法打开流:没有这样的文件或目录”?谢谢。是的,我有一个证书放在供应商/Facebook/fb\u ca\u chain\u捆绑包中。这张证书可以吗?我也已经安装了它。$arrContextOptions=array(“ssl”=>array(“cafile”=>“/Vendor/Facebook/fb\u ca\u chain\u bundle.crt”,“verify\u peer”=>true,“verify\u peer\u name”=>true,);我尝试了它,但未能加载crt文件,因此现在我使用另一种方法将verify_peer和verify_peer_name设置为false,只要证书有效且脚本可以访问,我认为您做得很好。请注意,对于下载证书捆绑包,请尝试以下操作:您的答案非常有用,我现在可以访问证书并尝试回显文件\u get\u内容,它有一个值,但现在剩余的错误是无法打开流:没有这样的文件或目录,我在文件文件夹下有一个文件夹名user\u profile,为什么它说没有这样的文件目录?您的意思是,在这个参数“cafile”=>“/path/to/bundle/ca bundle.crt”中,它说的是“无法打开流:没有这样的文件或目录”?