Since PHP 5.3.2 SNI is supported. This sends the host name to the server, before the header reaches the server (See http://en.wikipedia.org/wiki/Server_Name_Indication )
If the host name in SNI does not match the HTTP header, Apache answers with "400: Bad request" and logs "[error] Hostname xxx.xxx.xxx.xxx provided via SNI and hostname www.example.com provided via HTTP are different".
This is caused by the DNS cache used in PHPCrawl, as we do not pass the host name to fsockopen.
IMHO there are two solutions to fix this:
1. Disable DNS caching and use the hostname in every request (slow). I tested this, it works.
2. Set the host name in the request context:
$context = stream_context_create(array(
'ssl' => array('SNI_server_name' => 'www.example.com'),
$fp = stream_socket_client("tcp://xxx.xxx.xxx.xxx:443", $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $context);
And keep up the good work!