
I intend to connect to a certain server via a php socket. The code snippet is : $context = stream_context_create(array( 'tls'=>array( 'allow_self_signed' => 'TRUE', 'passphrase' => CERT_PASS, 'local_cert' =>CERT, 'cafile' => CA_file, ) )); if (!$this->socket = stream_socket_client($host . ':' . $port, $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, $context)) { die("Failed to connect:" . $errstr); } else { stream_set_timeout($this->socket, $timeout); return $this->getFrame(); } The various parameters are defined well e.g: define('CERT', dirname(__FILE__) . '/' . 'certificate.pem'); However, from the server where i am connecting to, i get the error: Connection has been shutdown: javax.net.ssl.SSLHandshakeException: null cert chain that is, a handshake error. From my logs (client side) i get: *Warning*: stream_socket_client() [function.stream-socket-client<http://afriregister.co.ke/uploaded/function.stream-socket-client>]: SSL operation failed with code 1. OpenSSL Error messages: error:140943F2:SSL routines:SSL3_READ_BYTES:sslv3 alert unexpected message *Warning*: stream_socket_client() [function.stream-socket-client<http://afriregister.co.ke/uploaded/function.stream-socket-client>]: Failed to enable crypto What could be the issue here? Using the Openssl commands: openssl s_client -connect server700 -cert certificate.pem -key key.pem Connects well and gives the greeting...which means the certificate is OK. What could be the issue here?Google doesn't seem to help.