PHP OpenSSL question
| From: | Pierre-Luc Soucy | Date: | Tue, 04 Mar 2003 15:58:37 +0000 |
| Subject: | PHP OpenSSL question | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-138122@lists.php.net to get a copy of this message | ||
Hi,
I have loaded the appropriate keys:
//load keys
$ca_file = openssl_x509_read('file://'.$ca_file);
$public_key = openssl_pkey_get_public('file://'.$public_key_file);
$private_key = openssl_pkey_get_private('file://'.$private_key_file);
and can successfully encrypt data:
$to_send = '<?xml version="1.0" encoding="UTF-8"
standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0
epp-1.0.xsd">
<hello/>
</epp>';
openssl_public_encrypt($to_send, $message, $public_key);
I then write the encrypted data to the socket using socket_write (when
communicating with a server) but the server disconnects me when I attempt to
read its output with socket_read:
Warning: socket_read() unable to read from socket [54]: Connection reset by
peer
Any idea why? To what I understand, I might need to do a SSL handshake
first? How can that be done with PHP?
Thanks a lot!
Pierre-Luc Soucy