1--TEST--
2openssl_cms_sign() and openssl_cms_verify() tests
3--EXTENSIONS--
4openssl
5--FILE--
6<?php
7$infile = __DIR__ . "/plain.txt";
8$outfile = tempnam(sys_get_temp_dir(), "ssl");
9$vout= $outfile . ".vout";
10
11if ($outfile === false) {
12    die("failed to get a temporary filename!");
13}
14
15$privkey = "file://" . __DIR__ . "/private_rsa_1024.key";
16$single_cert = "file://" . __DIR__ . "/cert.crt";
17$assoc_headers = array("To" => "test@test", "Subject" => "testing openssl_cms_sign()");
18$headers = array("test@test", "testing openssl_cms_sign()");
19$empty_headers = array();
20$wrong = "wrong";
21$empty = "";
22print("Plain text:\n");
23readfile($infile);
24var_dump(openssl_cms_sign($infile, $outfile, openssl_x509_read($single_cert), $privkey, $headers));
25var_dump(openssl_cms_verify($outfile,OPENSSL_CMS_NOVERIFY, NULL, array(), NULL, $vout));
26print("\nValidated content:\n");
27readfile($vout);
28
29if (file_exists($outfile)) {
30    echo "true\n";
31    unlink($outfile);
32}
33if (file_exists($vout)) {
34    echo "true\n";
35    unlink($vout);
36}
37?>
38--EXPECT--
39Plain text:
40Now is the winter of our discontent.
41bool(true)
42bool(true)
43
44Validated content:
45Now is the winter of our discontent.
46true
47true
48