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 windows only test'); 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_SSLv2_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_SSLv23_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_SSLv2_SERVER)); 26 var_dump(stream_socket_enable_crypto($sock, true, STREAM_CRYPTO_METHOD_SSLv3_SERVER)); 27 var_dump(stream_socket_enable_crypto($sock, true, STREAM_CRYPTO_METHOD_SSLv23_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) 45bool(false) 46 47Warning: 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. 48 in %s on line %d 49bool(false) 50 51Warning: stream_socket_enable_crypto(): SSL/TLS already set-up for this stream 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