1--TEST--
2mixed stream_socket_enable_crypto(resource $stream , bool $enable [, int $crypto_type [, resource $session_stream ]] ) ;
3--CREDITS--
4marcosptf - <marcosptf@yahoo.com.br> - #phparty7 - @phpsp - novatec/2015 - sao paulo - br
5--SKIPIF--
6<?php
7if (!extension_loaded('openssl')) {
8	die('skip ext openssl required');
9}
10if (substr(PHP_OS, 0, 3) != 'WIN' ) {
11	die('skip windows only test');
12}
13?>
14--FILE--
15<?php
16$serverUri = "tcp://127.0.0.1:31854";
17$sock = stream_socket_server($serverUri, $errno, $errstr);
18
19if (is_resource($sock)) {
20  var_dump(stream_socket_enable_crypto($sock, false));
21  var_dump(stream_socket_enable_crypto($sock, true));
22  var_dump(stream_socket_enable_crypto($sock, true, STREAM_CRYPTO_METHOD_SSLv2_CLIENT));
23  var_dump(stream_socket_enable_crypto($sock, true, STREAM_CRYPTO_METHOD_SSLv3_CLIENT));
24  var_dump(stream_socket_enable_crypto($sock, true, STREAM_CRYPTO_METHOD_SSLv23_CLIENT));
25  var_dump(stream_socket_enable_crypto($sock, true, STREAM_CRYPTO_METHOD_TLS_CLIENT));
26  var_dump(stream_socket_enable_crypto($sock, true, STREAM_CRYPTO_METHOD_SSLv2_SERVER));
27  var_dump(stream_socket_enable_crypto($sock, true, STREAM_CRYPTO_METHOD_SSLv3_SERVER));
28  var_dump(stream_socket_enable_crypto($sock, true, STREAM_CRYPTO_METHOD_SSLv23_SERVER));
29  var_dump(stream_socket_enable_crypto($sock, true, STREAM_CRYPTO_METHOD_TLS_SERVER));
30} else {
31  die("Test stream_socket_enable_crypto has failed; Unable to connect: {$errstr} ({$errno})");
32}
33?>
34--CLEAN--
35<?php
36unset($serverUri);
37unset($sock);
38unset($errno);
39unset($errstr);
40?>
41--EXPECTF--
42bool(false)
43
44Warning: stream_socket_enable_crypto(): When enabling encryption you must specify the crypto type in %s on line %d
45bool(false)
46
47Warning: stream_socket_enable_crypto(): SSLv2 unavailable in this PHP version in %s on line %d
48bool(false)
49
50Warning: stream_socket_enable_crypto(): SSL: A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied.
51 in %s on line %d
52bool(false)
53
54Warning: stream_socket_enable_crypto(): SSL/TLS already set-up for this stream in %s on line %d
55bool(false)
56
57Warning: stream_socket_enable_crypto(): SSL/TLS already set-up for this stream in %s on line %d
58bool(false)
59
60Warning: stream_socket_enable_crypto(): SSL/TLS already set-up for this stream in %s on line %d
61bool(false)
62
63Warning: stream_socket_enable_crypto(): SSL/TLS already set-up for this stream in %s on line %d
64bool(false)
65
66Warning: stream_socket_enable_crypto(): SSL/TLS already set-up for this stream in %s on line %d
67bool(false)
68
69Warning: stream_socket_enable_crypto(): SSL/TLS already set-up for this stream in %s on line %d
70bool(false)
71