I'm using PHP 5.0 on Windows XP, and I'm trying to use
stream_socket_client to attach to an SSL socket server. Something like
this:
$host = "localhost";
$port = 9999;
$context = stream_context_create();
stream_context_set_option($context, 'ssl', 'local_cert', 'mycert.pem');
stream_context_set_option($context, 'ssl', 'passphrase', 'secret');
$where = "ssl://$host:$port";
$s = stream_socket_client($where, $errno, $errstr, 30, 0, $context);
var_dump($s);
This code runs. $s reports to be a stream resource, nothing is placed
in $errno or $errstr.
But it doesn't make a connection to the server. I know for certain
because I have a breakpoint in the server at "accept" (it's in C++)
that doesn't get hit.
Now, I've been single-stepping thru PHP's source code to see what I
might be missing. What I haven't stepped into yet is anything that
actually connects a socket to a server. It looks rather like that
should happen in php_openssl_ssl_socket_factory (a function in
xp_ssl.c) but it's not there.
Does stream_socket_client truly not work? I need to connect to an SSL
server and send a local certificate, which fsockopen (apparently)
doesn't allow.