1--TEST-- 2openssl_cms_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_cms_sign()"); 16$headers = array("test@test", "testing openssl_cms_sign()"); 17$empty_headers = array(); 18$wrong = "wrong"; 19$empty = ""; 20 21var_dump(openssl_cms_sign($infile, $outfile, openssl_x509_read($single_cert), $privkey, $headers)); 22$s = stat($outfile); 23if ($s['size'] < 500) { 24 print "size failure, not big enough."; 25} 26var_dump(openssl_cms_sign($infile, $outfile, $single_cert, $privkey, $headers)); 27var_dump(openssl_cms_sign($infile, $outfile, $single_cert, $privkey, $assoc_headers)); 28var_dump(openssl_cms_sign($infile, $outfile, $single_cert, $privkey, $empty_headers)); 29var_dump(openssl_cms_sign($wrong, $outfile, $single_cert, $privkey, $headers)); 30var_dump(openssl_cms_sign($empty, $outfile, $single_cert, $privkey, $headers)); 31var_dump(openssl_cms_sign($infile, $empty, $single_cert, $privkey, $headers)); 32var_dump(openssl_cms_sign($infile, $outfile, $wrong, $privkey, $headers)); 33var_dump(openssl_cms_sign($infile, $outfile, $empty, $privkey, $headers)); 34var_dump(openssl_cms_sign($infile, $outfile, $single_cert, $wrong, $headers)); 35 36if (file_exists($outfile)) { 37 echo "true\n"; 38 unlink($outfile); 39} 40?> 41--EXPECTF-- 42bool(true) 43bool(true) 44bool(true) 45bool(true) 46 47Warning: openssl_cms_sign(): Error opening input file %s in %s on line %d 48bool(false) 49 50Warning: openssl_cms_sign(): Error opening input file %s in %s on line %d 51bool(false) 52 53Warning: openssl_cms_sign(): Error opening output file %s in %s on line %d 54bool(false) 55 56Warning: openssl_cms_sign(): X.509 Certificate cannot be retrieved in %s on line %d 57bool(false) 58 59Warning: openssl_cms_sign(): X.509 Certificate cannot be retrieved in %s on line %d 60bool(false) 61 62Warning: openssl_cms_sign(): Error getting private key in %s on line %d 63bool(false) 64true 65