1--TEST-- 2openssl_pkcs7_sign() tests 3--SKIPIF-- 4<?php if (!extension_loaded("openssl")) print "skip"; ?> 5--FILE-- 6<?php 7$infile = __DIR__ . "/cert.crt"; 8$outfile = tempnam(sys_get_temp_dir(), "ssl"); 9if ($outfile === false) { 10 die("failed to get a temporary filename!"); 11} 12 13$privkey = "file://" . __DIR__ . "/private_rsa_1024.key"; 14$single_cert = "file://" . __DIR__ . "/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, openssl_x509_read($single_cert), $privkey, $headers)); 22var_dump(openssl_pkcs7_sign($infile, $outfile, $single_cert, $privkey, $headers)); 23var_dump(openssl_pkcs7_sign($infile, $outfile, $single_cert, $privkey, $assoc_headers)); 24var_dump(openssl_pkcs7_sign($infile, $outfile, $single_cert, $privkey, $empty_headers)); 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, $wrong, $headers)); 31 32if (file_exists($outfile)) { 33 echo "true\n"; 34 unlink($outfile); 35} 36?> 37--EXPECTF-- 38bool(true) 39bool(true) 40bool(true) 41bool(true) 42 43Warning: openssl_pkcs7_sign(): Error opening input file wrong! in %s on line %d 44bool(false) 45 46Warning: openssl_pkcs7_sign(): Error opening input file ! in %s on line %d 47bool(false) 48 49Warning: openssl_pkcs7_sign(): Error opening output file ! in %s on line %d 50bool(false) 51 52Warning: openssl_pkcs7_sign(): X.509 Certificate cannot be retrieved in %s on line %d 53bool(false) 54 55Warning: openssl_pkcs7_sign(): X.509 Certificate cannot be retrieved in %s on line %d 56bool(false) 57 58Warning: openssl_pkcs7_sign(): Error getting private key in %s on line %d 59bool(false) 60true 61