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} 10?> 11--FILE-- 12<?php 13$serverUri = "tcp://127.0.0.1:31854"; 14$sock = stream_socket_server($serverUri, $errno, $errstr); 15 16if (is_resource($sock)) { 17 var_dump(stream_socket_enable_crypto($sock, false)); 18 var_dump(stream_socket_enable_crypto($sock, true)); 19 var_dump(stream_socket_enable_crypto($sock, true, STREAM_CRYPTO_METHOD_SSLv23_CLIENT)); 20 var_dump(stream_socket_enable_crypto($sock, true, STREAM_CRYPTO_METHOD_SSLv3_CLIENT)); 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_TLS_CLIENT)); 23 var_dump(stream_socket_enable_crypto($sock, true, STREAM_CRYPTO_METHOD_SSLv23_SERVER)); 24 var_dump(stream_socket_enable_crypto($sock, true, STREAM_CRYPTO_METHOD_SSLv2_SERVER)); 25 var_dump(stream_socket_enable_crypto($sock, true, STREAM_CRYPTO_METHOD_SSLv3_SERVER)); 26 var_dump(stream_socket_enable_crypto($sock, true, STREAM_CRYPTO_METHOD_TLS_SERVER)); 27} else { 28 die("Test stream_socket_enable_crypto has failed; Unable to connect: {$errstr} ({$errno})"); 29} 30?> 31--CLEAN-- 32<?php 33unset($serverUri); 34unset($sock); 35unset($errno); 36unset($errstr); 37?> 38--EXPECTF-- 39bool(false) 40 41Warning: stream_socket_enable_crypto(): When enabling encryption you must specify the crypto type in %s on line %d 42bool(false) 43 44Warning: stream_socket_enable_crypto(): SSL: %a in %s on line %d 45bool(false) 46 47Warning: stream_socket_enable_crypto(): SSL/TLS already set-up for this stream 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