stream_socket_client():Failed to enable crypto

程序如下:

1
2
3
4
5
6
$ctx = stream_context_create();
$pem = dirname(__FILE__) . '' . 'ck20120130.pem';
stream_context_set_option($ctx, 'ssl', 'local_cert', $pem);
stream_context_set_option($ctx, 'ssl', 'passphrase', $pass);
$fp = stream_socket_client($serverUrl, $err, $errstr, 60,
STREAM_CLIENT_CONNECT, $ctx);

运行报如下错误:

1
2
3
Warning: stream_socket_client() [function.stream-socket-client]: SSL 运维 failed with code 1. OpenSSL Error messages: error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure
Warning: stream_socket_client() [function.stream-socket-client]: Failed to enable crypto
Warning: stream_socket_client() [function.stream-socket-client]: unable to connect to ssl

最后检查了一下,发现是$pem地址的问题,改成dirname(__FILE__) . ‘/‘ . ‘ck20120130.pem’就没有问题了。

坚持原创技术分享,您的支持将鼓励我继续创作!