PHPCrawl无法创建SSL套接字 [英] PHPCrawl fails to create SSL socket

查看:141
本文介绍了PHPCrawl无法创建SSL套接字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用PHPCrawl( http://sourceforge.net/projects/phpcrawl/)搜索通过HTTPS传送的网站。

I'm trying to use PHPCrawl (http://sourceforge.net/projects/phpcrawl/) to trawl a website delivered over HTTPS.

我可以看到PHPCrawlerHTTPRequest类中支持SSL(openSocket方法):

I can see that there is support for SSL in the PHPCrawlerHTTPRequest class (openSocket method):

// If ssl -> perform Server name indication
  if ($this->url_parts["protocol"] == "https://")
  {
    $context = stream_context_create(array('ssl' => array('SNI_server_name' => $this->url_parts["host"])));
    $this->socket = @stream_socket_client($protocol_prefix.$ip_address.":".$this->url_parts["port"], $error_code, $error_str,
                                          $this->socketConnectTimeout, STREAM_CLIENT_CONNECT, $context);
  }

问题在于对stream_socket_client的调用 - 尽管它返回零error_code,并且没有error_str,this-> socket仍为false。

The problem lies in the call to stream_socket_client - although it returns a zero error_code, and no error_str, this->socket is still false.

该方法的文档说明如下:

The documentation for the method states the following:


如果errno中返回的值为0且函数返回FALSE,则表示错误发生在connect()调用之前。

If the value returned in errno is 0 and the function returned FALSE, it is an indication that the error occurred before the connect() call.

(参见 http://php.net/manual/en/function.stream-socket-client.php

所以我试图使用评论部分提供的示例来修改流上下文,使用'stream_context_set_option'将verify_host和verify_peer设置为false - 两者似乎都没有任何效果。

So I've tried to use an example provided in the comments section to modify the stream context using 'stream_context_set_option' to set verify_host and verify_peer to false - neither of which seems to have any effect.

我不是很精通PHP或者网络错综复杂 - 有没有人知道:

I'm not very proficient in PHP or the intricacies of web - does anyone know either:


  • 什么条件(具体)会导致此调用失败吗?
    OR

  • 问题的解决方法?

我应该注意 - 我我使用Facebook(HTTPS)作为测试服务器。

I should note - I am using Facebook (HTTPS) as the test server.

推荐答案

我发现了这个问题 -

I've found the issue -


  • PHP版本5.6.x默认启用对等验证,显然有时找不到necesarry证书(查看此错误报告

解决方法是回退到5.6之前的PHP版本

The workaround is to drop back to a PHP version prior to 5.6

这篇关于PHPCrawl无法创建SSL套接字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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