php-src/ext/openssl/tests/openssl_pkcs7_verify_basic.phpt
Jelle van der Waa f3d22e4999
openssl: Add basic openssl_pkcs7_verify tests
Add basic openssl_pkcs7_verify tests, which verifies a signed email,
extracts the signed certificate and the body of the email.
2017-06-01 08:12:25 +01:00

48 lines
1 KiB
PHP

--TEST--
openssl_pkcs7_verify() tests
--SKIPIF--
<?php if (!extension_loaded("openssl")) print "skip"; ?>
--FILE--
<?php
$outfile = tempnam(sys_get_temp_dir(), "ssl");
if ($outfile === false) {
die("failed to get a temporary filename!");
}
$contentfile = tempnam(sys_get_temp_dir(), "ssl");
if ($contentfile === false) {
die("failed to get a temporary filename!");
}
$infile = dirname(__FILE__) . "/cert.crt";
$eml = dirname(__FILE__) . "/signed.eml";
$wrong = "wrong";
$empty = "";
$cainfo = array();
var_dump(openssl_pkcs7_verify($wrong, 0));
var_dump(openssl_pkcs7_verify($empty, 0));
var_dump(openssl_pkcs7_verify($eml, 0));
var_dump(openssl_pkcs7_verify($eml, 0, $empty));
var_dump(openssl_pkcs7_verify($eml, PKCS7_NOVERIFY, $outfile));
var_dump(openssl_pkcs7_verify($eml, PKCS7_NOVERIFY, $outfile, $cainfo, $outfile, $contentfile));
if (file_exists($outfile)) {
echo "true\n";
unlink($outfile);
}
if (file_exists($contentfile)) {
echo "true\n";
unlink($contentfile);
}
?>
--EXPECTF--
int(-1)
int(-1)
bool(false)
bool(false)
bool(true)
bool(true)
true
true