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 (phpversion() < "5.3.0") { die('SKIP php version so lower.'); }
8if (!extension_loaded('openssl')) { die('skip ext/openssl required'); }
9if(substr(PHP_OS, 0, 3) == 'WIN' ) {
10	die('skip not for windows');
11}
12?>
13--FILE--
14<?php
15$serverUri = "tcp://127.0.0.1:31854";
16$sock = stream_socket_server($serverUri, $errno, $errstr);
17
18if (is_resource($sock)) {
19  var_dump(stream_socket_enable_crypto($sock, false));
20  var_dump(stream_socket_enable_crypto($sock, true));
21  var_dump(stream_socket_enable_crypto($sock, true, STREAM_CRYPTO_METHOD_SSLv23_CLIENT));
22  var_dump(stream_socket_enable_crypto($sock, true, STREAM_CRYPTO_METHOD_SSLv3_CLIENT));
23  var_dump(stream_socket_enable_crypto($sock, true, STREAM_CRYPTO_METHOD_SSLv2_CLIENT));
24  var_dump(stream_socket_enable_crypto($sock, true, STREAM_CRYPTO_METHOD_TLS_CLIENT));
25  var_dump(stream_socket_enable_crypto($sock, true, STREAM_CRYPTO_METHOD_SSLv23_SERVER));
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_TLS_SERVER));
29} else {
30  die("Test stream_socket_enable_crypto has failed; Unable to connect: {$errstr} ({$errno})");
31}
32?>
33--CLEAN--
34<?php
35unset($serverUri);
36unset($sock);
37unset($errno);
38unset($errstr);
39?>
40--EXPECTF--
41bool(false)
42
43Warning: stream_socket_enable_crypto(): When enabling encryption you must specify the crypto type in %s on line %d
44bool(false)
45
46Warning: stream_socket_enable_crypto(): SSL: Broken pipe in %s on line %d
47bool(false)
48
49Warning: stream_socket_enable_crypto(): SSL/TLS already set-up for this stream in %s on line %d
50bool(false)
51
52Warning: stream_socket_enable_crypto(): SSL/TLS already set-up for this stream in %s on line %d
53bool(false)
54
55Warning: stream_socket_enable_crypto(): SSL/TLS already set-up for this stream in %s on line %d
56bool(false)
57
58Warning: stream_socket_enable_crypto(): SSL/TLS already set-up for this stream in %s on line %d
59bool(false)
60
61Warning: stream_socket_enable_crypto(): SSL/TLS already set-up for this stream in %s on line %d
62bool(false)
63
64Warning: stream_socket_enable_crypto(): SSL/TLS already set-up for this stream in %s on line %d
65bool(false)
66
67Warning: stream_socket_enable_crypto(): SSL/TLS already set-up for this stream in %s on line %d
68bool(false)
69