xref: /PHP-5.5/ext/openssl/tests/025.phpt (revision d3538f42)
1--TEST--
2openssl_pkcs7_sign() tests
3--SKIPIF--
4<?php if (!extension_loaded("openssl")) print "skip"; ?>
5--FILE--
6<?php
7$infile = dirname(__FILE__) . "/cert.crt";
8$outfile = tempnam("/tmp", "ssl");
9if ($outfile === false)
10	die("failed to get a temporary filename!");
11
12$privkey = "file://" . dirname(__FILE__) . "/private.key";
13$single_cert = "file://" . dirname(__FILE__) . "/cert.crt";
14$assoc_headers = array("To" => "test@test", "Subject" => "testing openssl_pkcs7_sign()");
15$headers = array("test@test", "testing openssl_pkcs7_sign()");
16$empty_headers = array();
17$wrong = "wrong";
18$empty = "";
19
20var_dump(openssl_pkcs7_sign($infile, $outfile, $single_cert, $privkey, $headers));
21var_dump(openssl_pkcs7_sign($infile, $outfile, $single_cert, $privkey, $assoc_headers));
22var_dump(openssl_pkcs7_sign($infile, $outfile, $single_cert, $privkey, $empty_headers));
23var_dump(openssl_pkcs7_sign($infile, $outfile, $single_cert, $privkey, $wrong));
24var_dump(openssl_pkcs7_sign($wrong, $outfile, $single_cert, $privkey, $headers));
25var_dump(openssl_pkcs7_sign($empty, $outfile, $single_cert, $privkey, $headers));
26var_dump(openssl_pkcs7_sign($infile, $empty, $single_cert, $privkey, $headers));
27var_dump(openssl_pkcs7_sign($infile, $outfile, $wrong, $privkey, $headers));
28var_dump(openssl_pkcs7_sign($infile, $outfile, $empty, $privkey, $headers));
29var_dump(openssl_pkcs7_sign($infile, $outfile, $single_cert, $privkey, $empty));
30var_dump(openssl_pkcs7_sign($infile, $outfile, $single_cert, $wrong, $headers));
31
32if (file_exists($outfile)) {
33	echo "true\n";
34	unlink($outfile);
35}
36?>
37--EXPECTF--
38bool(true)
39bool(true)
40bool(true)
41
42Warning: openssl_pkcs7_sign() expects parameter 5 to be array, string given in %s on line %d
43NULL
44
45Warning: openssl_pkcs7_sign(): error opening input file %s in %s on line %d
46bool(false)
47
48Warning: openssl_pkcs7_sign(): error opening input file %s in %s on line %d
49bool(false)
50
51Warning: openssl_pkcs7_sign(): error opening output file %s in %s on line %d
52bool(false)
53
54Warning: openssl_pkcs7_sign(): error getting cert in %s on line %d
55bool(false)
56
57Warning: openssl_pkcs7_sign(): error getting cert in %s on line %d
58bool(false)
59
60Warning: openssl_pkcs7_sign() expects parameter 5 to be array, string given in %s on line %d
61NULL
62
63Warning: openssl_pkcs7_sign(): error getting private key in %s on line %d
64bool(false)
65true
66