xref: /PHP-8.0/ext/openssl/tests/bug62890.phpt (revision bc7ea73d)
1--TEST--
2Bug #62890 (default_socket_timeout=-1 causes connection to timeout)
3--SKIPIF--
4<?php
5if (!extension_loaded('openssl')) die('skip openssl extension not available');
6if (!function_exists("proc_open")) die("skip no proc_open");
7?>
8--INI--
9default_socket_timeout=-1
10--FILE--
11<?php
12$certFile = __DIR__ . DIRECTORY_SEPARATOR . 'bug62890.pem.tmp';
13
14$serverCode = <<<'CODE'
15    $flags = STREAM_SERVER_BIND|STREAM_SERVER_LISTEN;
16    $ctx = stream_context_create(['ssl' => [
17        'local_cert' => '%s',
18        'security_level' => 1,
19    ]]);
20
21    $server = stream_socket_server('tls://127.0.0.1:64321', $errno, $errstr, $flags, $ctx);
22    phpt_notify();
23    @stream_socket_accept($server, 3);
24CODE;
25$serverCode = sprintf($serverCode, $certFile);
26
27$clientCode = <<<'CODE'
28    $flags = STREAM_CLIENT_CONNECT;
29    $ctx = stream_context_create(['ssl' => [
30        'verify_peer' => false,
31        'verify_peer_name' => false,
32        'security_level' => 1,
33    ]]);
34
35    phpt_wait();
36
37    $client = stream_socket_client("tls://127.0.0.1:64321", $errno, $errstr, 3, $flags, $ctx);
38    var_dump($client);
39CODE;
40
41include 'CertificateGenerator.inc';
42$certificateGenerator = new CertificateGenerator();
43$certificateGenerator->saveNewCertAsFileWithKey('bug62890', $certFile);
44
45include 'ServerClientTestCase.inc';
46ServerClientTestCase::getInstance()->run($clientCode, $serverCode);
47?>
48--CLEAN--
49<?php
50@unlink(__DIR__ . DIRECTORY_SEPARATOR . 'bug62890.pem.tmp');
51?>
52--EXPECTF--
53resource(%d) of type (stream)
54