1--TEST--
2openssl_pkcs7_verify() tests
3--SKIPIF--
4<?php if (!extension_loaded("openssl")) print "skip"; ?>
5--FILE--
6<?php
7$outfile = tempnam(sys_get_temp_dir(), "ssl");
8if ($outfile === false) {
9    die("failed to get a temporary filename!");
10}
11
12$contentfile = tempnam(sys_get_temp_dir(), "ssl");
13if ($contentfile === false) {
14    die("failed to get a temporary filename!");
15}
16
17$pkcsfile = __DIR__ . "/openssl_pkcs7_verify__pkcsfile.tmp";
18$eml = __DIR__ . "/signed.eml";
19$wrong = "wrong";
20$empty = "";
21$cainfo = array();
22
23var_dump(openssl_pkcs7_verify($wrong, 0));
24var_dump(openssl_pkcs7_verify($empty, 0));
25var_dump(openssl_pkcs7_verify($eml, 0));
26var_dump(openssl_pkcs7_verify($eml, 0, $empty));
27var_dump(openssl_pkcs7_verify($eml, PKCS7_NOVERIFY, $outfile));
28var_dump(openssl_pkcs7_verify($eml, PKCS7_NOVERIFY, $outfile, $cainfo, $outfile, $contentfile));
29var_dump(openssl_pkcs7_verify($eml, PKCS7_NOVERIFY, $outfile, $cainfo, $outfile, $contentfile, $pkcsfile));
30var_dump(file_get_contents($pkcsfile));
31
32if (file_exists($outfile)) {
33    echo "true\n";
34    unlink($outfile);
35}
36
37if (file_exists($contentfile)) {
38    echo "true\n";
39    unlink($contentfile);
40}
41?>
42--CLEAN--
43<?php
44unlink(__DIR__ . DIRECTORY_SEPARATOR . '/openssl_pkcs7_verify__pkcsfile.tmp');
45?>
46--EXPECTF--
47int(-1)
48int(-1)
49bool(false)
50bool(false)
51bool(true)
52bool(true)
53bool(true)
54string(20%d) "-----BEGIN PKCS7-----
55MIIFzQYJKoZIhvcNAQcCoIIFvjCCBboCAQExDzANBglghkgBZQMEAgEFADALBgkq
56hkiG9w0BBwGgggNwMIIDbDCCAtWgAwIBAgIJAK7FVsxyN1CiMA0GCSqGSIb3DQEB
57BQUAMIGBMQswCQYDVQQGEwJCUjEaMBgGA1UECBMRUmlvIEdyYW5kZSBkbyBTd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