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 not for windows'); 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_SSLv23_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_SSLv2_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_SSLv23_SERVER)); 27 var_dump(stream_socket_enable_crypto($sock, true, STREAM_CRYPTO_METHOD_SSLv2_SERVER)); 28 var_dump(stream_socket_enable_crypto($sock, true, STREAM_CRYPTO_METHOD_SSLv3_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(): SSL: Broken pipe in %s on line %d 48bool(false) 49 50Warning: stream_socket_enable_crypto(): SSL/TLS already set-up for this stream in %s on line %d 51bool(false) 52 53Warning: stream_socket_enable_crypto(): SSL/TLS already set-up for this stream in %s on line %d 54bool(false) 55 56Warning: stream_socket_enable_crypto(): SSL/TLS already set-up for this stream in %s on line %d 57bool(false) 58 59Warning: stream_socket_enable_crypto(): SSL/TLS already set-up for this stream in %s on line %d 60bool(false) 61 62Warning: stream_socket_enable_crypto(): SSL/TLS already set-up for this stream in %s on line %d 63bool(false) 64 65Warning: stream_socket_enable_crypto(): SSL/TLS already set-up for this stream in %s on line %d 66bool(false) 67 68Warning: stream_socket_enable_crypto(): SSL/TLS already set-up for this stream in %s on line %d 69bool(false) 70