Hi,
Well, this has been fun. I'm not normally a PHP guy, but right now I
need to move some data from an HTTPS server into PHP. Problem is that
I'm trying to do it properly, confirming that the servers certificate
says what it should and that it isn't self signed (i.e. the chain of
trust extends all the way up to the root). I've been at this for
getting on for two days now and have got this far:
if (function_exists('openssl_open')) echo('Not a dumbarse');
$sc=stream_context_create();
$rtn=stream_context_set_option($sc,'ssl', 'verify_peer', true);
$rtn=stream_context_set_option($sc,'ssl', 'allow_self_signed',
false);
$sock=fsockopen('ssl://development.atomicdroplet.com',443,$errno,
$errstr,30,$sc);
if ($sock) {
fwrite($sock,"GET /msg_serve/123/ HTTP /1.0\r\n\r\n");
while ($contents=fread($sock,8192)) echo $contents;
fclose($sock);
};
Now, I actually just tripped across the fsockopen call using a stream
context (my IDE autocompleted it for me) and it's not covered in the
docs. I also wanted to use stream_socket_client but realistically
have to target the 4.x branch, probably all the way back to 4.3.0.
The error I get is #36, "Operation now in progress". Commenting out
the two stream_context_set_option calls makes it work properly ...
but also completely defeats the purpose of trying to establish the
real identity of the other end.
I could also use curl, but it seems rare that it is installed.
Any guidance is gratefully received ... as I said, this has taken
rather a long time and my patience is wearing thin :(
Dave
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php