Skip to content

Commit 2a9dd98

Browse files
committed
Merge branch 'PHP-7.0'
2 parents 00a2c30 + 1ff88d3 commit 2a9dd98

7 files changed

+80
-80
lines changed

ext/openssl/tests/openssl_x509_check_private_key_basic.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ openssl_x509_check_private_key() tests
55
--FILE--
66
<?php
77
$fp = fopen(dirname(__FILE__) . "/cert.crt","r");
8-
$a = fread($fp,8192);
8+
$a = fread($fp, 8192);
99
fclose($fp);
1010

1111
$fp = fopen(dirname(__FILE__) . "/private_rsa_1024.key","r");
12-
$b = fread($fp,8192);
12+
$b = fread($fp, 8192);
1313
fclose($fp);
1414

1515
$cert = "file://" . dirname(__FILE__) . "/cert.crt";

ext/openssl/tests/openssl_x509_export_basic.phpt

Lines changed: 11 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,22 @@
11
--TEST--
2-
openssl_x509_export() and openssl_x509_export_to_file() tests
2+
openssl_x509_export() tests
33
--SKIPIF--
44
<?php if (!extension_loaded("openssl")) print "skip"; ?>
55
--FILE--
66
<?php
7-
$fp = fopen(dirname(__FILE__) . "/cert.crt","r");
8-
$a = fread($fp,8192);
9-
fclose($fp);
7+
$cert_file = dirname(__FILE__) . "/cert.crt";
108

11-
$b = "file://" . dirname(__FILE__) . "/cert.crt";
9+
$a = file_get_contents($cert_file);
10+
$b = "file://" . $cert_file;
1211
$c = "invalid cert";
1312
$d = openssl_x509_read($a);
1413
$e = array();
1514

16-
var_dump(openssl_x509_export($a, $output)); // read cert as a binary string
17-
var_dump(openssl_x509_export($b, $output2)); // read cert from a filename string
18-
var_dump(openssl_x509_export($c, $output3)); // read an invalid cert, fails
19-
var_dump(openssl_x509_export($d, $output4)); // read cert from a resource
20-
var_dump(openssl_x509_export($e, $output5)); // read an array, fails
21-
22-
$outfilename = tempnam("/tmp", "ssl");
23-
if ($outfilename === false) {
24-
die("failed to get a temporary filename!");
25-
}
26-
27-
echo "---\n";
28-
29-
var_dump(openssl_x509_export_to_file($a, $outfilename)); // read cert as a binary string
30-
var_dump(openssl_x509_export_to_file($b, $outfilename)); // read cert from a filename string
31-
var_dump(openssl_x509_export_to_file($c, $outfilename)); // read an invalid cert, fails
32-
var_dump(openssl_x509_export_to_file($d, $outfilename)); // read cert from a resource
33-
var_dump(openssl_x509_export_to_file($e, $outfilename)); // read an array, fails
34-
echo "---\n";
35-
36-
var_dump($exists = file_exists($outfilename));
37-
if ($exists) {
38-
@unlink($outfilename);
39-
}
40-
echo "---\n";
15+
var_dump(openssl_x509_export($a, $output)); // read cert as a binary string
16+
var_dump(openssl_x509_export($b, $output2)); // read cert from a filename string
17+
var_dump(openssl_x509_export($c, $output3)); // read an invalid cert, fails
18+
var_dump(openssl_x509_export($d, $output4)); // read cert from a resource
19+
var_dump(openssl_x509_export($e, $output5)); // read an array, fails
4120

4221
if (PHP_EOL !== "\n") {
4322
$a = str_replace(PHP_EOL, "\n", $a);
@@ -46,9 +25,8 @@ if (PHP_EOL !== "\n") {
4625
var_dump(strcmp($output, $a));
4726
var_dump(strcmp($output, $output2));
4827
var_dump(strcmp($output, $output3));
49-
var_dump(strcmp($output, $output4)); // different
50-
var_dump(strcmp($output, $output5)); // different
51-
28+
var_dump(strcmp($output, $output4)); // different
29+
var_dump(strcmp($output, $output5)); // different
5230
?>
5331
--EXPECTF--
5432
bool(true)
@@ -60,19 +38,6 @@ bool(true)
6038

6139
Warning: openssl_x509_export(): cannot get cert from parameter 1 in %s on line %d
6240
bool(false)
63-
---
64-
bool(true)
65-
bool(true)
66-
67-
Warning: openssl_x509_export_to_file(): cannot get cert from parameter 1 in %s on line %d
68-
bool(false)
69-
bool(true)
70-
71-
Warning: openssl_x509_export_to_file(): cannot get cert from parameter 1 in %s on line %d
72-
bool(false)
73-
---
74-
bool(true)
75-
---
7641
int(0)
7742
int(0)
7843
int(%d)
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
--TEST--
2+
openssl_x509_export_to_file() tests
3+
--SKIPIF--
4+
<?php if (!extension_loaded("openssl")) print "skip"; ?>
5+
--FILE--
6+
<?php
7+
$outfilename = dirname(__FILE__) . "/openssl_x509_export_to_file__outfilename.tmp";
8+
$cert_file = dirname(__FILE__) . "/cert.crt";
9+
10+
$a = file_get_contents($cert_file);
11+
$b = "file://" . $cert_file;
12+
$c = "invalid cert";
13+
$d = openssl_x509_read($a);
14+
$e = array();
15+
16+
var_dump(openssl_x509_export_to_file($a, $outfilename)); // read cert as a binary string
17+
var_dump(openssl_x509_export_to_file($b, $outfilename)); // read cert from a filename string
18+
var_dump(openssl_x509_export_to_file($c, $outfilename)); // read an invalid cert, fails
19+
var_dump(openssl_x509_export_to_file($d, $outfilename)); // read cert from a resource
20+
var_dump(openssl_x509_export_to_file($e, $outfilename)); // read an array, fails
21+
echo "---\n";
22+
var_dump($exists = file_exists($outfilename));
23+
?>
24+
--CLEAN--
25+
<?php
26+
$outfilename = dirname(__FILE__) . "/openssl_x509_export_to_file__outfilename.tmp";
27+
if (file_exists($outfilename)) {
28+
unlink($outfilename);
29+
}
30+
?>
31+
--EXPECTF--
32+
bool(true)
33+
bool(true)
34+
35+
Warning: openssl_x509_export_to_file(): cannot get cert from parameter 1 in %s on line %d
36+
bool(false)
37+
bool(true)
38+
39+
Warning: openssl_x509_export_to_file(): cannot get cert from parameter 1 in %s on line %d
40+
bool(false)
41+
---
42+
bool(true)

ext/openssl/tests/openssl_x509_fingerprint_basic.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
Testing openssl_x509_fingerprint()
2+
openssl_x509_fingerprint() tests
33
--SKIPIF--
44
<?php
55
if (!extension_loaded("openssl")) die("skip");
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
openssl_x509_free() tests
3+
--SKIPIF--
4+
<?php if (!extension_loaded("openssl")) print "skip"; ?>
5+
--FILE--
6+
<?php
7+
var_dump($res = openssl_x509_read("file://" . dirname(__FILE__) . "/cert.crt"));
8+
openssl_x509_free($res);
9+
var_dump($res);
10+
openssl_x509_free(false);
11+
?>
12+
--EXPECTF--
13+
resource(%d) of type (OpenSSL X.509)
14+
resource(%d) of type (Unknown)
15+
16+
Warning: openssl_x509_free() expects parameter 1 to be resource, boolean given in %s on line %d

ext/openssl/tests/openssl_x509_parse_basic.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
openssl_x509_parse() basic test
2+
openssl_x509_parse() tests
33
--SKIPIF--
44
<?php if (!extension_loaded("openssl")) print "skip";
55
if (OPENSSL_VERSION_NUMBER < 0x10000000) die("skip Output requires OpenSSL 1.0");
Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
openssl_x509_read() tests with testing openssl_x509_free as well
2+
openssl_x509_read() tests
33
--SKIPIF--
44
<?php if (!extension_loaded("openssl")) print "skip"; ?>
55
--FILE--
@@ -14,47 +14,24 @@ $d = openssl_x509_read($a);
1414
$e = array();
1515
$f = array($b);
1616

17-
var_dump($res = openssl_x509_read($a)); // read cert as a string
18-
openssl_x509_free($res);
19-
var_dump($res);
20-
var_dump($res = openssl_x509_read($b)); // read cert as a filename string
21-
openssl_x509_free($res);
22-
var_dump($res);
23-
var_dump($res = openssl_x509_read($c)); // read an invalid cert, fails
24-
openssl_x509_free($res);
25-
var_dump($res);
26-
var_dump($res = openssl_x509_read($d)); // read cert from a resource
27-
openssl_x509_free($res);
28-
var_dump($res);
29-
var_dump($res = openssl_x509_read($e)); // read an array
30-
openssl_x509_free($res);
31-
var_dump($res);
32-
var_dump($res = openssl_x509_read($f)); // read an array with the filename
33-
openssl_x509_free($res);
34-
var_dump($res);
17+
var_dump(openssl_x509_read($a)); // read cert as a string
18+
var_dump(openssl_x509_read($b)); // read cert as a filename string
19+
var_dump(openssl_x509_read($c)); // read an invalid cert, fails
20+
var_dump(openssl_x509_read($d)); // read cert from a resource
21+
var_dump(openssl_x509_read($e)); // read an array
22+
var_dump(openssl_x509_read($f)); // read an array with the filename
3523
?>
3624
--EXPECTF--
3725
resource(%d) of type (OpenSSL X.509)
38-
resource(%d) of type (Unknown)
3926
resource(%d) of type (OpenSSL X.509)
40-
resource(%d) of type (Unknown)
4127

4228
Warning: openssl_x509_read(): supplied parameter cannot be coerced into an X509 certificate! in %s on line %d
4329
bool(false)
44-
45-
Warning: openssl_x509_free() expects parameter 1 to be resource, boolean given in %s on line %d
46-
bool(false)
4730
resource(%d) of type (OpenSSL X.509)
48-
resource(%d) of type (Unknown)
4931

5032
Warning: openssl_x509_read(): supplied parameter cannot be coerced into an X509 certificate! in %s on line %d
5133
bool(false)
5234

53-
Warning: openssl_x509_free() expects parameter 1 to be resource, boolean given in %s on line %d
54-
bool(false)
55-
5635
Warning: openssl_x509_read(): supplied parameter cannot be coerced into an X509 certificate! in %s on line %d
5736
bool(false)
5837

59-
Warning: openssl_x509_free() expects parameter 1 to be resource, boolean given in %s on line %d
60-
bool(false)

0 commit comments

Comments
 (0)