1--TEST--
2openssl_cms_verify() der 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_cms_verify__pkcsfile.tmp";
18$eml = __DIR__ . "/signed.eml";
19$wrong = "wrong";
20$empty = "";
21$cainfo = array();
22$plain = __DIR__ . "/plain.txt";
23$p7file = __DIR__ . "/shakespeare.p7s";
24$pemfile = __DIR__ . "/shakespeare.pem";
25var_dump(openssl_cms_verify($wrong, 0));
26var_dump(openssl_cms_verify($empty, 0));
27var_dump(openssl_cms_verify($eml, 0));
28var_dump(openssl_cms_verify($eml, 0, $empty));
29var_dump(openssl_cms_verify($eml, OPENSSL_CMS_NOVERIFY, $outfile));
30var_dump(openssl_cms_verify($eml, OPENSSL_CMS_NOVERIFY, $outfile, $cainfo, $outfile, $contentfile));
31var_dump(openssl_cms_verify($eml, OPENSSL_CMS_NOVERIFY, $outfile, $cainfo, $outfile, $contentfile, $pkcsfile));
32var_dump(openssl_cms_verify($plain, OPENSSL_CMS_NOVERIFY|OPENSSL_CMS_BINARY|OPENSSL_CMS_DETACHED,$outfile,$cainfo,NULL,$contentfile,$pkcsfile,$p7file,OPENSSL_ENCODING_DER));
33var_dump(openssl_cms_verify($plain, OPENSSL_CMS_NOVERIFY|OPENSSL_CMS_BINARY|OPENSSL_CMS_DETACHED,$outfile,$cainfo,NULL,$contentfile,$pkcsfile,$pemfile,OPENSSL_ENCODING_PEM));
34var_dump(file_get_contents($pkcsfile));
35
36if (file_exists($outfile)) {
37    echo "true\n";
38    unlink($outfile);
39}
40
41if (file_exists($contentfile)) {
42    echo "true\n";
43    unlink($contentfile);
44}
45?>
46--CLEAN--
47<?php
48unlink(__DIR__ . DIRECTORY_SEPARATOR . '/openssl_cms_verify__pkcsfile.tmp');
49?>
50--EXPECT--
51bool(false)
52bool(false)
53bool(false)
54bool(false)
55bool(true)
56bool(true)
57bool(true)
58bool(true)
59bool(true)
60string(2049) "-----BEGIN CMS-----
61MIIFyQYJKoZIhvcNAQcCoIIFujCCBbYCAQExDTALBglghkgBZQMEAgEwCwYJKoZI
62hvcNAQcBoIIDcDCCA2wwggLVoAMCAQICCQCuxVbMcjdQojANBgkqhkiG9w0BAQUF
63ADCBgTELMAkGA1UEBhMCQlIxGjAYBgNVBAgTEVJpbyBHcmFuZGUgZG8gU3VsMRUw
64EwYDVQQHEwxQb3J0byBBbGVncmUxHjAcBgNVBAMTFUhlbnJpcXVlIGRvIE4uIEFu
65Z2VsbzEfMB0GCSqGSIb3DQEJARYQaG5hbmdlbG9AcGhwLm5ldDAeFw0wODA2MzAx
66MDI4NDNaFw0wODA3MzAxMDI4NDNaMIGBMQswCQYDVQQGEwJCUjEaMBgGA1UECBMR
67UmlvIEdyYW5kZSBkbyBTdWwxFTATBgNVBAcTDFBvcnRvIEFsZWdyZTEeMBwGA1UE
68AxMVSGVucmlxdWUgZG8gTi4gQW5nZWxvMR8wHQYJKoZIhvcNAQkBFhBobmFuZ2Vs
69b0BwaHAubmV0MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDLXp6PkCtbpV+P
701gwFQWH6Ez0U83uEmS8IGnpeI8Fk8rY/vHOZzZZaxRCw+loyc342qCDIQheMOCNm
715Fkevz06q757/oooiLR3yryYGKiKG1IZIiplmtsC95oKrzUSKk60wuI1mbgpMUP5
72LKi/Tvxes5PmkUtXfimz2qgkeUcPpQIDAQABo4HpMIHmMB0GA1UdDgQWBBTbfkBy
73vVw1hewpKYES6GJoarc/fTCBtgYDVR0jBIGuMIGrgBTbfkByvVw1hewpKYES6GJo
74arc/faGBh6SBhDCBgTELMAkGA1UEBhMCQlIxGjAYBgNVBAgTEVJpbyBHcmFuZGUg
75ZG8gU3VsMRUw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