1--TEST-- 2Basic bitwise stream crypto context flag assignment 3--EXTENSIONS-- 4openssl 5--SKIPIF-- 6<?php 7if (!function_exists("proc_open")) die("skip no proc_open"); 8?> 9--FILE-- 10<?php 11$certFile = __DIR__ . DIRECTORY_SEPARATOR . 'stream_crypto_flags_001.pem.tmp'; 12$cacertFile = __DIR__ . DIRECTORY_SEPARATOR . 'stream_crypto_flags_001-ca.pem.tmp'; 13 14$serverCode = <<<'CODE' 15 $serverUri = "ssl://127.0.0.1:64321"; 16 $serverFlags = STREAM_SERVER_BIND | STREAM_SERVER_LISTEN; 17 $serverCtx = stream_context_create(['ssl' => [ 18 'local_cert' => '%s', 19 'security_level' => 0, 20 ]]); 21 22 $server = stream_socket_server($serverUri, $errno, $errstr, $serverFlags, $serverCtx); 23 phpt_notify(); 24 25 @stream_socket_accept($server, 1); 26 @stream_socket_accept($server, 1); 27 @stream_socket_accept($server, 1); 28CODE; 29$serverCode = sprintf($serverCode, $certFile); 30 31$peerName = 'stream_crypto_flags_001'; 32$clientCode = <<<'CODE' 33 $serverUri = "ssl://127.0.0.1:64321"; 34 $clientFlags = STREAM_CLIENT_CONNECT; 35 $clientCtx = stream_context_create(['ssl' => [ 36 'verify_peer' => true, 37 'cafile' => '%s', 38 'peer_name' => '%s', 39 'security_level' => 0, 40 ]]); 41 42 phpt_wait(); 43 44 stream_context_set_option($clientCtx, 'ssl', 'crypto_method', STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT); 45 var_dump(stream_socket_client($serverUri, $errno, $errstr, 1, $clientFlags, $clientCtx)); 46 47 stream_context_set_option($clientCtx, 'ssl', 'crypto_method', STREAM_CRYPTO_METHOD_TLS_CLIENT); 48 var_dump(stream_socket_client($serverUri, $errno, $errstr, 1, $clientFlags, $clientCtx)); 49CODE; 50$clientCode = sprintf($clientCode, $cacertFile, $peerName); 51 52include 'CertificateGenerator.inc'; 53$certificateGenerator = new CertificateGenerator(); 54$certificateGenerator->saveCaCert($cacertFile); 55$certificateGenerator->saveNewCertAsFileWithKey($peerName, $certFile); 56 57include 'ServerClientTestCase.inc'; 58ServerClientTestCase::getInstance()->run($clientCode, $serverCode); 59?> 60--CLEAN-- 61<?php 62@unlink(__DIR__ . DIRECTORY_SEPARATOR . 'stream_crypto_flags_001.pem.tmp'); 63@unlink(__DIR__ . DIRECTORY_SEPARATOR . 'stream_crypto_flags_001-ca.pem.tmp'); 64?> 65--EXPECTF-- 66resource(%d) of type (stream) 67resource(%d) of type (stream) 68