Skip to content

Commit f57acf0

Browse files
ezimuelpetk
authored andcommitted
Added test for openssl_pkcs12_export_to_file_error
1 parent 3f93f15 commit f57acf0

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
--TEST--
2+
openssl_pkcs12_export_to_file() error tests
3+
--SKIPIF--
4+
<?php if (!extension_loaded("openssl")) print "skip"; ?>
5+
--FILE--
6+
<?php
7+
$pkcsfile = dirname(__FILE__) . "/openssl_pkcs12_export_to_file__pkcsfile.tmp";
8+
9+
$cert_file = dirname(__FILE__) . "/public.crt";
10+
$cert = file_get_contents($cert_file);
11+
$cert_path = "file://" . $cert_file;
12+
$priv_file = dirname(__FILE__) . "/private.crt";
13+
$priv = file_get_contents($priv_file);
14+
$wrong_priv_file = dirname(__FILE__) . "/private_rsa_1024.key";
15+
$wrong_priv = file_get_contents($wrong_priv_file);
16+
$pass = 'test';
17+
18+
var_dump(openssl_pkcs12_export_to_file($cert, $pkcsfile, null, $pass));
19+
var_dump(openssl_pkcs12_export_to_file($cert, $pkcsfile, $wrong_priv, $pass));
20+
var_dump(openssl_pkcs12_export_to_file($cert, '.', $priv, $pass));
21+
?>
22+
--CLEAN--
23+
<?php
24+
$pkcsfile = dirname(__FILE__) . "/openssl_pkcs12_export_to_file__pkcsfile.tmp";
25+
if (file_exists($pkcsfile)) {
26+
unlink($pkcsfile);
27+
}
28+
?>
29+
--EXPECTF--
30+
Warning: openssl_pkcs12_export_to_file(): cannot get private key from parameter 3 in %s on line %d
31+
bool(false)
32+
33+
Warning: openssl_pkcs12_export_to_file(): private key does not correspond to cert in %s on line %d
34+
bool(false)
35+
36+
Warning: openssl_pkcs12_export_to_file(): error opening file . in %s on line %d
37+
bool(false)

0 commit comments

Comments
 (0)