summaryrefslogtreecommitdiff
path: root/ext/openssl/tests/openssl_pkcs7_verify_basic.phpt
blob: 63b181e58844fbf6ee6ca6352c6b3f65332d69cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
--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!");
}

$pkcsfile = __DIR__ . "/openssl_pkcs7_verify__pkcsfile.tmp";
$eml = __DIR__ . "/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));
var_dump(openssl_pkcs7_verify($eml, PKCS7_NOVERIFY, $outfile, $cainfo, $outfile, $contentfile, $pkcsfile));
var_dump(file_get_contents($pkcsfile));

if (file_exists($outfile)) {
    echo "true\n";
    unlink($outfile);
}

if (file_exists($contentfile)) {
    echo "true\n";
    unlink($contentfile);
}
?>
--CLEAN--
<?php
unlink(__DIR__ . DIRECTORY_SEPARATOR . '/openssl_pkcs7_verify__pkcsfile.tmp');
?>
--EXPECTF--
int(-1)
int(-1)
bool(false)
bool(false)
bool(true)
bool(true)
bool(true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