Skip to content

Commit 5f349b7

Browse files
committed
Merge branch 'PHP-7.2'
2 parents 55277a6 + 77bd405 commit 5f349b7

File tree

88 files changed

+780
-707
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+780
-707
lines changed

ext/openssl/tests/001.phpt

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,43 @@ if (!@openssl_pkey_new()) die("skip cannot create private key");
99
<?php
1010
echo "Creating private key\n";
1111

12-
$conf = array('config' => dirname(__FILE__) . DIRECTORY_SEPARATOR . 'openssl.cnf');
12+
$conf = array('config' => __DIR__ . DIRECTORY_SEPARATOR . 'openssl.cnf');
1313
$privkey = openssl_pkey_new($conf);
1414

15-
if ($privkey === false)
16-
die("failed to create private key");
15+
if ($privkey === false) {
16+
die("failed to create private key");
17+
}
1718

1819
$passphrase = "banana";
19-
$key_file_name = tempnam(sys_get_temp_dir(), "ssl");
20-
if ($key_file_name === false)
21-
die("failed to get a temporary filename!");
20+
$key_file_name = __DIR__ . '/001-tmp.key';
21+
if ($key_file_name === false) {
22+
die("failed to get a temporary filename!");
23+
}
2224

2325
echo "Export key to file\n";
2426

25-
openssl_pkey_export_to_file($privkey, $key_file_name, $passphrase, $conf) or die("failed to export to file $key_file_name");
27+
if (!openssl_pkey_export_to_file($privkey, $key_file_name, $passphrase, $conf)) {
28+
die("failed to export to file $key_file_name");
29+
}
2630
var_dump(is_resource($privkey));
2731

2832
echo "Load key from file - array syntax\n";
2933

3034
$loaded_key = openssl_pkey_get_private(array("file://$key_file_name", $passphrase));
3135

32-
if ($loaded_key === false)
33-
die("failed to load key using array syntax");
36+
if ($loaded_key === false) {
37+
die("failed to load key using array syntax");
38+
}
3439

3540
openssl_pkey_free($loaded_key);
3641

3742
echo "Load key using direct syntax\n";
3843

3944
$loaded_key = openssl_pkey_get_private("file://$key_file_name", $passphrase);
4045

41-
if ($loaded_key === false)
42-
die("failed to load key using direct syntax");
46+
if ($loaded_key === false) {
47+
die("failed to load key using direct syntax");
48+
}
4349

4450
openssl_pkey_free($loaded_key);
4551

@@ -48,15 +54,13 @@ echo "Load key manually and use string syntax\n";
4854
$key_content = file_get_contents($key_file_name);
4955
$loaded_key = openssl_pkey_get_private($key_content, $passphrase);
5056

51-
if ($loaded_key === false)
52-
die("failed to load key using string syntax");
53-
57+
if ($loaded_key === false) {
58+
die("failed to load key using string syntax");
59+
}
5460
openssl_pkey_free($loaded_key);
5561

5662
echo "OK!\n";
5763

58-
@unlink($key_file_name);
59-
6064
?>
6165
--EXPECT--
6266
Creating private key
@@ -66,3 +70,8 @@ Load key from file - array syntax
6670
Load key using direct syntax
6771
Load key manually and use string syntax
6872
OK!
73+
--CLEAN--
74+
<?php
75+
$key_file_name = __DIR__ . DIRECTORY_SEPARATOR . '001-tmp.key';
76+
@unlink($key_file_name);
77+
?>

ext/openssl/tests/bug28382.phpt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
Bug #28382 (openssl_x509_parse extensions support)
33
--SKIPIF--
44
<?php
5-
if (!extension_loaded("openssl")) die("skip");
6-
if (OPENSSL_VERSION_NUMBER<0x009070af) die("skip");
5+
if (!extension_loaded("openssl")) die("skip");
76
?>
87
--FILE--
98
<?php

ext/openssl/tests/bug36732.phpt

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,21 @@ Bug #36732 (add support for req_extensions in openss_csr_new and sign)
33
--SKIPIF--
44
<?php
55
if (!extension_loaded("openssl")) die("skip");
6-
if (OPENSSL_VERSION_NUMBER < 0x009070af) die("skip");
76
?>
87
--FILE--
98
<?php
109
$configargs = array(
11-
"req_extensions" => "v3_req",
12-
"x509_extensions" => "usr_cert",
13-
"config" => __DIR__. DIRECTORY_SEPARATOR . "openssl.cnf",
10+
"req_extensions" => "v3_req",
11+
"x509_extensions" => "usr_cert",
12+
"config" => __DIR__. DIRECTORY_SEPARATOR . "openssl.cnf",
1413
);
1514

1615
$dn = array(
17-
"countryName" => "GB",
18-
"stateOrProvinceName" => "Berkshire",
19-
"localityName" => "Newbury",
20-
"organizationName" => "My Company Ltd",
21-
"commonName" => "Demo Cert"
16+
"countryName" => "GB",
17+
"stateOrProvinceName" => "Berkshire",
18+
"localityName" => "Newbury",
19+
"organizationName" => "My Company Ltd",
20+
"commonName" => "Demo Cert"
2221
);
2322

2423
$key = openssl_pkey_new();
@@ -29,11 +28,11 @@ $str = '';
2928
openssl_csr_export($csr, $str, false);
3029

3130
if (strpos($str, 'Requested Extensions:')) {
32-
echo "Ok\n";
31+
echo "Ok\n";
3332
}
3433
openssl_x509_export($crt, $str, false);
3534
if (strpos($str, 'X509v3 extensions:')) {
36-
echo "Ok\n";
35+
echo "Ok\n";
3736
}
3837
?>
3938
--EXPECT--

ext/openssl/tests/bug37820.phpt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ openssl_sign/verify: accept different algos
33
--SKIPIF--
44
<?php
55
if (!extension_loaded("openssl")) die("skip");
6-
if (OPENSSL_VERSION_NUMBER < 0x009070af) die("skip");
76
?>
87
--FILE--
98
<?php
@@ -15,19 +14,18 @@ $priv_key = file_get_contents($file_key);
1514
$priv_key_id = openssl_get_privatekey($priv_key);
1615

1716

18-
1917
$pub_key = file_get_contents($file_pub);
2018
$pub_key_id = openssl_get_publickey($pub_key);
2119
$data = "some custom data";
2220
if (!openssl_sign($data, $signature, $priv_key_id, OPENSSL_ALGO_MD5)) {
23-
echo "openssl_sign failed.";
21+
echo "openssl_sign failed.";
2422
}
2523

2624
$ok = openssl_verify($data, $signature, $pub_key_id, OPENSSL_ALGO_MD5);
2725
if ($ok == 1) {
28-
echo "Ok";
26+
echo "Ok";
2927
} elseif ($ok == 0) {
30-
echo "openssl_verify failed.";
28+
echo "openssl_verify failed.";
3129
}
3230

3331

ext/openssl/tests/bug38255.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ $signature = '';
1111
$ok = openssl_verify("foo", $signature, $pub_key_id, OPENSSL_ALGO_MD5);
1212

1313
class test {
14-
function __toString() {
15-
return "test object";
16-
}
14+
function __toString() {
15+
return "test object";
16+
}
1717
}
1818
$t = new test;
1919

ext/openssl/tests/bug38261.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ if (!extension_loaded("openssl")) die("skip");
88
<?php
99
$cert = false;
1010
class test {
11-
function __toString() {
12-
return "test object";
13-
}
11+
function __toString() {
12+
return "test object";
13+
}
1414
}
1515
$t = new test;
1616

ext/openssl/tests/bug39217.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ if (!extension_loaded("openssl")) die("skip");
99
$dir = dirname(__FILE__);
1010
$certs = array('bug39217cert2.txt', 'bug39217cert1.txt');
1111
foreach($certs as $cert) {
12-
$res = openssl_x509_parse(file_get_contents($dir . '/' . $cert));
13-
print_r($res['serialNumber']);
14-
echo "\n";
12+
$res = openssl_x509_parse(file_get_contents($dir . '/' . $cert));
13+
print_r($res['serialNumber']);
14+
echo "\n";
1515
}
1616
?>
1717
--EXPECT--

ext/openssl/tests/bug41033.phpt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
--SKIPIF--
44
<?php
55
if (!extension_loaded("openssl")) die("skip, openssl required");
6-
if (OPENSSL_VERSION_NUMBER < 0x009070af) die("skip");
76
?>
87
--FILE--
98
<?php

ext/openssl/tests/bug46127.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<?php
55
if (!extension_loaded("openssl")) die("skip openssl not loaded");
66
if (!function_exists("proc_open")) die("skip no proc_open");
7-
if (OPENSSL_VERSION_NUMBER < 0x009070af) die("skip openssl version too low");
7+
?>
88
--FILE--
99
<?php
1010
$serverCode = <<<'CODE'
@@ -38,5 +38,6 @@ CODE;
3838

3939
include 'ServerClientTestCase.inc';
4040
ServerClientTestCase::getInstance()->run($clientCode, $serverCode);
41+
?>
4142
--EXPECT--
4243
Sending bug 46127

ext/openssl/tests/bug48182.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Bug #48182: ssl handshake fails during asynchronous socket connection
44
<?php
55
if (!extension_loaded("openssl")) die("skip openssl not loaded");
66
if (!function_exists("proc_open")) die("skip no proc_open");
7-
if (OPENSSL_VERSION_NUMBER < 0x009070af) die("skip openssl version too low");
7+
?>
88
--FILE--
99
<?php
1010
$serverCode = <<<'CODE'
@@ -44,6 +44,7 @@ echo "Running bug48182\n";
4444

4545
include 'ServerClientTestCase.inc';
4646
ServerClientTestCase::getInstance()->run($clientCode, $serverCode);
47+
?>
4748
--EXPECT--
4849
Running bug48182
4950
Sending bug48182

ext/openssl/tests/bug54992.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Bug #54992: Stream not closed and error not returned when SSL CN_match fails
44
<?php
55
if (!extension_loaded("openssl")) die("skip openssl not loaded");
66
if (!function_exists("proc_open")) die("skip no proc_open");
7+
?>
78
--FILE--
89
<?php
910
$serverCode = <<<'CODE'
@@ -36,6 +37,7 @@ CODE;
3637

3738
include 'ServerClientTestCase.inc';
3839
ServerClientTestCase::getInstance()->run($clientCode, $serverCode);
40+
?>
3941
--EXPECTF--
4042
Warning: stream_socket_client(): Peer certificate CN=`bug54992.local' did not match expected CN=`buga_buga' in %s on line %d
4143

ext/openssl/tests/bug55259.phpt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ Bug #55259 (openssl extension does not get the DH parameters from DH key resourc
66
<?php
77

88
$phex = 'dcf93a0b883972ec0e19989ac5a2ce310e1d37717e8d9571bb7623731866e61e' .
9-
'f75a2e27898b057f9891c2e27a639c3f29b60814581cd3b2ca3986d268370557' .
10-
'7d45c2e7e52dc81c7a171876e5cea74b1448bfdfaf18828efd2519f14e45e382' .
11-
'6634af1949e5b535cc829a483b8a76223e5d490a257f05bdff16f2fb22c583ab';
12-
$dh_details = array( 'p' => $phex, 'g' => '2' );
13-
$dh = openssl_pkey_new(array( 'dh'=> array( 'p' => $phex, 'g' => '2' )));
9+
'f75a2e27898b057f9891c2e27a639c3f29b60814581cd3b2ca3986d268370557' .
10+
'7d45c2e7e52dc81c7a171876e5cea74b1448bfdfaf18828efd2519f14e45e382' .
11+
'6634af1949e5b535cc829a483b8a76223e5d490a257f05bdff16f2fb22c583ab';
12+
$dh_details = array('p' => $phex, 'g' => '2');
13+
$dh = openssl_pkey_new(array('dh'=> array('p' => $phex, 'g' => '2')));
1414
var_dump($dh);
15-
$dh = openssl_pkey_new(array( 'dh'=> array( 'p' => hex2bin($phex), 'g' => '2' )));
15+
$dh = openssl_pkey_new(array('dh'=> array( 'p' => hex2bin($phex), 'g' => '2')));
1616
$details = openssl_pkey_get_details($dh);
1717
var_dump(bin2hex($details['dh']['p']));
1818
var_dump($details['dh']['g']);

ext/openssl/tests/bug55646.phpt

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,43 @@
11
--TEST--
22
Bug #55646: textual input in openssl_csr_new() is not expected in UTF-8
33
--SKIPIF--
4-
<?php
5-
if (!function_exists('openssl_csr_new'))
6-
die('skip no openssl extension');
4+
<?php if (!extension_loaded("openssl")) die("skip"); ?>
75
--FILE--
86
<?php
9-
function stringAsHex($string){$unpacked = unpack("H*", $string);return implode(" ", str_split($unpacked[1],2));}
107

11-
$config = array("digest_alg" => "sha1","x509_extensions" => "v3_ca","req_extensions" => "v3_req","private_key_bits" => 2048,"private_key_type" => OPENSSL_KEYTYPE_RSA,"encrypt_key" => false,);
8+
function stringAsHex($string) {
9+
$unpacked = unpack("H*", $string);
10+
return implode(" ", str_split($unpacked[1],2));
11+
}
12+
13+
$config = array(
14+
"digest_alg" => "sha1",
15+
"x509_extensions" => "v3_ca",
16+
"req_extensions" => "v3_req",
17+
"private_key_bits" => 2048,
18+
"private_key_type" => OPENSSL_KEYTYPE_RSA,
19+
"encrypt_key" => false,
20+
);
1221
$csr_info = array(
13-
"countryName" => "US",
14-
"stateOrProvinceName" => "Utah",
15-
"localityName" => "Lindon",
16-
"organizationName" => "Chinese",
17-
"organizationalUnitName" => "IT \xe4\xba\x92",
18-
"commonName" => "www.example.com",);
22+
"countryName" => "US",
23+
"stateOrProvinceName" => "Utah",
24+
"localityName" => "Lindon",
25+
"organizationName" => "Chinese",
26+
"organizationalUnitName" => "IT \xe4\xba\x92",
27+
"commonName" => "www.example.com",
28+
);
1929
$private = openssl_pkey_new($config);
2030
while (openssl_error_string()) {}
21-
$csr_res = openssl_csr_new($csr_info, $private,
22-
['config' => __DIR__. DIRECTORY_SEPARATOR . "openssl.cnf"]);
31+
$csr_res = openssl_csr_new(
32+
$csr_info,
33+
$private,
34+
['config' => __DIR__. DIRECTORY_SEPARATOR . "openssl.cnf"]
35+
);
2336
if (!$csr_res) {
24-
while ($e = openssl_error_string()) { $err = $e; }
25-
die("Failed; last error: $err");
37+
while ($e = openssl_error_string()) {
38+
$err = $e;
39+
}
40+
die("Failed; last error: $err");
2641
}
2742
openssl_csr_export($csr_res, $csr);
2843
$output = openssl_csr_get_subject($csr);
@@ -31,6 +46,7 @@ echo "A: ".$csr_info["organizationalUnitName"]."\n";
3146
echo "B: ".stringAsHex($csr_info["organizationalUnitName"])."\n";
3247
echo "C: ".$output['OU']."\n";
3348
echo "D: ".stringAsHex($output['OU'])."\n";
49+
?>
3450
--EXPECT--
3551
A: IT 互
3652
B: 49 54 20 e4 ba 92

ext/openssl/tests/bug61930.phpt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ $data = <<<DATA
1212
Please verify me
1313
DATA;
1414

15-
$sig = 'f9Gyb6NV/ENn7GUa37ygTLcF93XHf5fbFTnoYF/O+fXbq3iChGUbET0RuhOsptlAODi6JsDLnJO4ikcVZo0tC1fFTj3LyCuPy3ZdgJbbVxQ/rviROCmuMFTqUW/Xa2LQYiapeCCgLQeWTLg7TM/BoHEkKbKLG/XT5jHvep1758A=';
15+
$sig = 'f9Gyb6NV/ENn7GUa37ygTLcF93XHf5fbFTnoYF/O+fXbq3iChGUbET0RuhOsptl' .
16+
'AODi6JsDLnJO4ikcVZo0tC1fFTj3LyCuPy3ZdgJbbVxQ/rviROCmuMFTqUW/Xa2' .
17+
'LQYiapeCCgLQeWTLg7TM/BoHEkKbKLG/XT5jHvep1758A=';
1618

1719
$key = openssl_get_publickey($cert);
1820
var_dump(openssl_get_publickey($key));

ext/openssl/tests/bug65538_001.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Bug #65538: SSL context "cafile" supports stream wrappers
44
<?php
55
if (!extension_loaded("openssl")) die("skip openssl not loaded");
66
if (!function_exists("proc_open")) die("skip no proc_open");
7+
?>
78
--FILE--
89
<?php
910
$serverCode = <<<'CODE'
@@ -48,5 +49,6 @@ CODE;
4849

4950
include 'ServerClientTestCase.inc';
5051
ServerClientTestCase::getInstance()->run($clientCode, $serverCode);
52+
?>
5153
--EXPECT--
5254
string(12) "Hello World!"

ext/openssl/tests/bug65538_002.phpt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ if (getenv("SKIP_ONLINE_TESTS")) die("skip online test");
88
--FILE--
99
<?php
1010
$clientCtx = stream_context_create(['ssl' => [
11-
// We don't get any ca list from php.net but it does not matter as we
12-
// care about the fact that the external stream is not allowed.
13-
// We can't use http://curl.haxx.se/ca/cacert.pem for this test
14-
// as it is redirected to https which means the test would depend
15-
// on system cafile when opening stream.
16-
'cafile' => 'http://www.php.net',
11+
// We don't get any ca list from php.net but it does not matter as we
12+
// care about the fact that the external stream is not allowed.
13+
// We can't use http://curl.haxx.se/ca/cacert.pem for this test
14+
// as it is redirected to https which means the test would depend
15+
// on system cafile when opening stream.
16+
'cafile' => 'http://www.php.net',
1717
]]);
1818
file_get_contents('https://github.com', false, $clientCtx);
1919
?>

0 commit comments

Comments
 (0)