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