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 13$privkey = "file://" . dirname(__FILE__) . "/private_rsa_1024.key"; 14$single_cert = "file://" . dirname(__FILE__) . "/cert.crt"; 15$assoc_headers = array("To" => "test@test", "Subject" => "testing openssl_pkcs7_sign()"); 16$headers = array("test@test", "testing openssl_pkcs7_sign()"); 17$empty_headers = array(); 18$wrong = "wrong"; 19$empty = ""; 20 21var_dump(openssl_pkcs7_sign($infile, $outfile, $single_cert, $privkey, $headers)); 22var_dump(openssl_pkcs7_sign($infile, $outfile, $single_cert, $privkey, $assoc_headers)); 23var_dump(openssl_pkcs7_sign($infile, $outfile, $single_cert, $privkey, $empty_headers)); 24var_dump(openssl_pkcs7_sign($infile, $outfile, $single_cert, $privkey, $wrong)); 25var_dump(openssl_pkcs7_sign($wrong, $outfile, $single_cert, $privkey, $headers)); 26var_dump(openssl_pkcs7_sign($empty, $outfile, $single_cert, $privkey, $headers)); 27var_dump(openssl_pkcs7_sign($infile, $empty, $single_cert, $privkey, $headers)); 28var_dump(openssl_pkcs7_sign($infile, $outfile, $wrong, $privkey, $headers)); 29var_dump(openssl_pkcs7_sign($infile, $outfile, $empty, $privkey, $headers)); 30var_dump(openssl_pkcs7_sign($infile, $outfile, $single_cert, $privkey, $empty)); 31var_dump(openssl_pkcs7_sign($infile, $outfile, $single_cert, $wrong, $headers)); 32 33if (file_exists($outfile)) { 34 echo "true\n"; 35 unlink($outfile); 36} 37?> 38--EXPECTF-- 39bool(true) 40bool(true) 41bool(true) 42 43Warning: openssl_pkcs7_sign() expects parameter 5 to be array, string given in %s on line %d 44NULL 45 46Warning: openssl_pkcs7_sign(): error opening input file %s in %s on line %d 47bool(false) 48 49Warning: openssl_pkcs7_sign(): error opening input file %s in %s on line %d 50bool(false) 51 52Warning: openssl_pkcs7_sign(): error opening output file %s in %s on line %d 53bool(false) 54 55Warning: openssl_pkcs7_sign(): error getting cert in %s on line %d 56bool(false) 57 58Warning: openssl_pkcs7_sign(): error getting cert in %s on line %d 59bool(false) 60 61Warning: openssl_pkcs7_sign() expects parameter 5 to be array, string given in %s on line %d 62NULL 63 64Warning: openssl_pkcs7_sign(): error getting private key in %s on line %d 65bool(false) 66true 67