mirror of
https://github.com/php/php-src.git
synced 2026-03-30 04:02:19 +02:00
Merge branch 'PHP-7.0'
This commit is contained in:
@@ -5,11 +5,11 @@ openssl_x509_check_private_key() tests
|
||||
--FILE--
|
||||
<?php
|
||||
$fp = fopen(dirname(__FILE__) . "/cert.crt","r");
|
||||
$a = fread($fp,8192);
|
||||
$a = fread($fp, 8192);
|
||||
fclose($fp);
|
||||
|
||||
$fp = fopen(dirname(__FILE__) . "/private_rsa_1024.key","r");
|
||||
$b = fread($fp,8192);
|
||||
$b = fread($fp, 8192);
|
||||
fclose($fp);
|
||||
|
||||
$cert = "file://" . dirname(__FILE__) . "/cert.crt";
|
||||
|
||||
@@ -1,43 +1,22 @@
|
||||
--TEST--
|
||||
openssl_x509_export() and openssl_x509_export_to_file() tests
|
||||
openssl_x509_export() tests
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("openssl")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
$fp = fopen(dirname(__FILE__) . "/cert.crt","r");
|
||||
$a = fread($fp,8192);
|
||||
fclose($fp);
|
||||
$cert_file = dirname(__FILE__) . "/cert.crt";
|
||||
|
||||
$b = "file://" . dirname(__FILE__) . "/cert.crt";
|
||||
$a = file_get_contents($cert_file);
|
||||
$b = "file://" . $cert_file;
|
||||
$c = "invalid cert";
|
||||
$d = openssl_x509_read($a);
|
||||
$e = array();
|
||||
|
||||
var_dump(openssl_x509_export($a, $output)); // read cert as a binary string
|
||||
var_dump(openssl_x509_export($b, $output2)); // read cert from a filename string
|
||||
var_dump(openssl_x509_export($c, $output3)); // read an invalid cert, fails
|
||||
var_dump(openssl_x509_export($d, $output4)); // read cert from a resource
|
||||
var_dump(openssl_x509_export($e, $output5)); // read an array, fails
|
||||
|
||||
$outfilename = tempnam("/tmp", "ssl");
|
||||
if ($outfilename === false) {
|
||||
die("failed to get a temporary filename!");
|
||||
}
|
||||
|
||||
echo "---\n";
|
||||
|
||||
var_dump(openssl_x509_export_to_file($a, $outfilename)); // read cert as a binary string
|
||||
var_dump(openssl_x509_export_to_file($b, $outfilename)); // read cert from a filename string
|
||||
var_dump(openssl_x509_export_to_file($c, $outfilename)); // read an invalid cert, fails
|
||||
var_dump(openssl_x509_export_to_file($d, $outfilename)); // read cert from a resource
|
||||
var_dump(openssl_x509_export_to_file($e, $outfilename)); // read an array, fails
|
||||
echo "---\n";
|
||||
|
||||
var_dump($exists = file_exists($outfilename));
|
||||
if ($exists) {
|
||||
@unlink($outfilename);
|
||||
}
|
||||
echo "---\n";
|
||||
var_dump(openssl_x509_export($a, $output)); // read cert as a binary string
|
||||
var_dump(openssl_x509_export($b, $output2)); // read cert from a filename string
|
||||
var_dump(openssl_x509_export($c, $output3)); // read an invalid cert, fails
|
||||
var_dump(openssl_x509_export($d, $output4)); // read cert from a resource
|
||||
var_dump(openssl_x509_export($e, $output5)); // read an array, fails
|
||||
|
||||
if (PHP_EOL !== "\n") {
|
||||
$a = str_replace(PHP_EOL, "\n", $a);
|
||||
@@ -46,9 +25,8 @@ if (PHP_EOL !== "\n") {
|
||||
var_dump(strcmp($output, $a));
|
||||
var_dump(strcmp($output, $output2));
|
||||
var_dump(strcmp($output, $output3));
|
||||
var_dump(strcmp($output, $output4)); // different
|
||||
var_dump(strcmp($output, $output5)); // different
|
||||
|
||||
var_dump(strcmp($output, $output4)); // different
|
||||
var_dump(strcmp($output, $output5)); // different
|
||||
?>
|
||||
--EXPECTF--
|
||||
bool(true)
|
||||
@@ -60,19 +38,6 @@ bool(true)
|
||||
|
||||
Warning: openssl_x509_export(): cannot get cert from parameter 1 in %s on line %d
|
||||
bool(false)
|
||||
---
|
||||
bool(true)
|
||||
bool(true)
|
||||
|
||||
Warning: openssl_x509_export_to_file(): cannot get cert from parameter 1 in %s on line %d
|
||||
bool(false)
|
||||
bool(true)
|
||||
|
||||
Warning: openssl_x509_export_to_file(): cannot get cert from parameter 1 in %s on line %d
|
||||
bool(false)
|
||||
---
|
||||
bool(true)
|
||||
---
|
||||
int(0)
|
||||
int(0)
|
||||
int(%d)
|
||||
|
||||
42
ext/openssl/tests/openssl_x509_export_to_file_basic.phpt
Normal file
42
ext/openssl/tests/openssl_x509_export_to_file_basic.phpt
Normal file
@@ -0,0 +1,42 @@
|
||||
--TEST--
|
||||
openssl_x509_export_to_file() tests
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("openssl")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
$outfilename = dirname(__FILE__) . "/openssl_x509_export_to_file__outfilename.tmp";
|
||||
$cert_file = dirname(__FILE__) . "/cert.crt";
|
||||
|
||||
$a = file_get_contents($cert_file);
|
||||
$b = "file://" . $cert_file;
|
||||
$c = "invalid cert";
|
||||
$d = openssl_x509_read($a);
|
||||
$e = array();
|
||||
|
||||
var_dump(openssl_x509_export_to_file($a, $outfilename)); // read cert as a binary string
|
||||
var_dump(openssl_x509_export_to_file($b, $outfilename)); // read cert from a filename string
|
||||
var_dump(openssl_x509_export_to_file($c, $outfilename)); // read an invalid cert, fails
|
||||
var_dump(openssl_x509_export_to_file($d, $outfilename)); // read cert from a resource
|
||||
var_dump(openssl_x509_export_to_file($e, $outfilename)); // read an array, fails
|
||||
echo "---\n";
|
||||
var_dump($exists = file_exists($outfilename));
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
$outfilename = dirname(__FILE__) . "/openssl_x509_export_to_file__outfilename.tmp";
|
||||
if (file_exists($outfilename)) {
|
||||
unlink($outfilename);
|
||||
}
|
||||
?>
|
||||
--EXPECTF--
|
||||
bool(true)
|
||||
bool(true)
|
||||
|
||||
Warning: openssl_x509_export_to_file(): cannot get cert from parameter 1 in %s on line %d
|
||||
bool(false)
|
||||
bool(true)
|
||||
|
||||
Warning: openssl_x509_export_to_file(): cannot get cert from parameter 1 in %s on line %d
|
||||
bool(false)
|
||||
---
|
||||
bool(true)
|
||||
@@ -1,5 +1,5 @@
|
||||
--TEST--
|
||||
Testing openssl_x509_fingerprint()
|
||||
openssl_x509_fingerprint() tests
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("openssl")) die("skip");
|
||||
|
||||
16
ext/openssl/tests/openssl_x509_free_basic.phpt
Normal file
16
ext/openssl/tests/openssl_x509_free_basic.phpt
Normal file
@@ -0,0 +1,16 @@
|
||||
--TEST--
|
||||
openssl_x509_free() tests
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("openssl")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
var_dump($res = openssl_x509_read("file://" . dirname(__FILE__) . "/cert.crt"));
|
||||
openssl_x509_free($res);
|
||||
var_dump($res);
|
||||
openssl_x509_free(false);
|
||||
?>
|
||||
--EXPECTF--
|
||||
resource(%d) of type (OpenSSL X.509)
|
||||
resource(%d) of type (Unknown)
|
||||
|
||||
Warning: openssl_x509_free() expects parameter 1 to be resource, boolean given in %s on line %d
|
||||
@@ -1,5 +1,5 @@
|
||||
--TEST--
|
||||
openssl_x509_parse() basic test
|
||||
openssl_x509_parse() tests
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("openssl")) print "skip";
|
||||
if (OPENSSL_VERSION_NUMBER < 0x10000000) die("skip Output requires OpenSSL 1.0");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
--TEST--
|
||||
openssl_x509_read() tests with testing openssl_x509_free as well
|
||||
openssl_x509_read() tests
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("openssl")) print "skip"; ?>
|
||||
--FILE--
|
||||
@@ -14,47 +14,24 @@ $d = openssl_x509_read($a);
|
||||
$e = array();
|
||||
$f = array($b);
|
||||
|
||||
var_dump($res = openssl_x509_read($a)); // read cert as a string
|
||||
openssl_x509_free($res);
|
||||
var_dump($res);
|
||||
var_dump($res = openssl_x509_read($b)); // read cert as a filename string
|
||||
openssl_x509_free($res);
|
||||
var_dump($res);
|
||||
var_dump($res = openssl_x509_read($c)); // read an invalid cert, fails
|
||||
openssl_x509_free($res);
|
||||
var_dump($res);
|
||||
var_dump($res = openssl_x509_read($d)); // read cert from a resource
|
||||
openssl_x509_free($res);
|
||||
var_dump($res);
|
||||
var_dump($res = openssl_x509_read($e)); // read an array
|
||||
openssl_x509_free($res);
|
||||
var_dump($res);
|
||||
var_dump($res = openssl_x509_read($f)); // read an array with the filename
|
||||
openssl_x509_free($res);
|
||||
var_dump($res);
|
||||
var_dump(openssl_x509_read($a)); // read cert as a string
|
||||
var_dump(openssl_x509_read($b)); // read cert as a filename string
|
||||
var_dump(openssl_x509_read($c)); // read an invalid cert, fails
|
||||
var_dump(openssl_x509_read($d)); // read cert from a resource
|
||||
var_dump(openssl_x509_read($e)); // read an array
|
||||
var_dump(openssl_x509_read($f)); // read an array with the filename
|
||||
?>
|
||||
--EXPECTF--
|
||||
resource(%d) of type (OpenSSL X.509)
|
||||
resource(%d) of type (Unknown)
|
||||
resource(%d) of type (OpenSSL X.509)
|
||||
resource(%d) of type (Unknown)
|
||||
|
||||
Warning: openssl_x509_read(): supplied parameter cannot be coerced into an X509 certificate! in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: openssl_x509_free() expects parameter 1 to be resource, boolean given in %s on line %d
|
||||
bool(false)
|
||||
resource(%d) of type (OpenSSL X.509)
|
||||
resource(%d) of type (Unknown)
|
||||
|
||||
Warning: openssl_x509_read(): supplied parameter cannot be coerced into an X509 certificate! in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: openssl_x509_free() expects parameter 1 to be resource, boolean given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: openssl_x509_read(): supplied parameter cannot be coerced into an X509 certificate! in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: openssl_x509_free() expects parameter 1 to be resource, boolean given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Reference in New Issue
Block a user