Annotation of embedaddon/php/ext/openssl/tests/024.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: openssl_pkcs7_decrypt() tests
! 3: --SKIPIF--
! 4: <?php if (!extension_loaded("openssl")) print "skip"; ?>
! 5: --FILE--
! 6: <?php
! 7: $infile = dirname(__FILE__) . "/cert.crt";
! 8: $privkey = "file://" . dirname(__FILE__) . "/private.key";
! 9: $encrypted = tempnam("/tmp", "ssl");
! 10: if ($encrypted === false)
! 11: die("failed to get a temporary filename!");
! 12: $outfile = tempnam("/tmp", "ssl");
! 13: if ($outfile === false) {
! 14: unlink($outfile);
! 15: die("failed to get a temporary filename!");
! 16: }
! 17:
! 18: $single_cert = "file://" . dirname(__FILE__) . "/cert.crt";
! 19: $headers = array("test@test", "testing openssl_pkcs7_encrypt()");
! 20: $wrong = "wrong";
! 21: $empty = "";
! 22:
! 23: openssl_pkcs7_encrypt($infile, $encrypted, $single_cert, $headers);
! 24: var_dump(openssl_pkcs7_decrypt($encrypted, $outfile, $single_cert, $privkey));
! 25: var_dump(openssl_pkcs7_decrypt($encrypted, $outfile, $single_cert, $wrong));
! 26: var_dump(openssl_pkcs7_decrypt($encrypted, $outfile, $wrong, $privkey));
! 27: var_dump(openssl_pkcs7_decrypt($encrypted, $outfile, null, $privkey));
! 28: var_dump(openssl_pkcs7_decrypt($wrong, $outfile, $single_cert, $privkey));
! 29: var_dump(openssl_pkcs7_decrypt($empty, $outfile, $single_cert, $privkey));
! 30: var_dump(openssl_pkcs7_decrypt($encrypted, $empty, $single_cert, $privkey));
! 31: var_dump(openssl_pkcs7_decrypt($encrypted, $outfile, $empty, $privkey));
! 32: var_dump(openssl_pkcs7_decrypt($encrypted, $outfile, $single_cert, $empty));
! 33:
! 34: if (file_exists($encrypted)) {
! 35: echo "true\n";
! 36: unlink($encrypted);
! 37: }
! 38: if (file_exists($outfile)) {
! 39: echo "true\n";
! 40: unlink($outfile);
! 41: }
! 42: ?>
! 43: --EXPECTF--
! 44: bool(true)
! 45:
! 46: Warning: openssl_pkcs7_decrypt(): unable to get private key in %s on line %d
! 47: bool(false)
! 48:
! 49: Warning: openssl_pkcs7_decrypt(): unable to coerce parameter 3 to x509 cert in %s on line %d
! 50: bool(false)
! 51:
! 52: Warning: openssl_pkcs7_decrypt(): unable to coerce parameter 3 to x509 cert in %s on line %d
! 53: bool(false)
! 54: bool(false)
! 55: bool(false)
! 56: bool(false)
! 57:
! 58: Warning: openssl_pkcs7_decrypt(): unable to coerce parameter 3 to x509 cert in %s on line %d
! 59: bool(false)
! 60:
! 61: Warning: openssl_pkcs7_decrypt(): unable to get private key in %s on line %d
! 62: bool(false)
! 63: true
! 64: true
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>