diff options
Diffstat (limited to 'ext/openssl/tests/001.phpt')
-rw-r--r-- | ext/openssl/tests/001.phpt | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/ext/openssl/tests/001.phpt b/ext/openssl/tests/001.phpt index 9bcb3d890e..7f5af24ae6 100644 --- a/ext/openssl/tests/001.phpt +++ b/ext/openssl/tests/001.phpt @@ -9,28 +9,33 @@ if (!@openssl_pkey_new()) die("skip cannot create private key"); <?php echo "Creating private key\n"; -$conf = array('config' => dirname(__FILE__) . DIRECTORY_SEPARATOR . 'openssl.cnf'); +$conf = array('config' => __DIR__ . DIRECTORY_SEPARATOR . 'openssl.cnf'); $privkey = openssl_pkey_new($conf); -if ($privkey === false) - die("failed to create private key"); +if ($privkey === false) { + die("failed to create private key"); +} $passphrase = "banana"; -$key_file_name = tempnam(sys_get_temp_dir(), "ssl"); -if ($key_file_name === false) - die("failed to get a temporary filename!"); +$key_file_name = __DIR__ . '/001-tmp.key'; +if ($key_file_name === false) { + die("failed to get a temporary filename!"); +} echo "Export key to file\n"; -openssl_pkey_export_to_file($privkey, $key_file_name, $passphrase, $conf) or die("failed to export to file $key_file_name"); +if (!openssl_pkey_export_to_file($privkey, $key_file_name, $passphrase, $conf)) { + die("failed to export to file $key_file_name"); +} var_dump(is_resource($privkey)); echo "Load key from file - array syntax\n"; $loaded_key = openssl_pkey_get_private(array("file://$key_file_name", $passphrase)); -if ($loaded_key === false) - die("failed to load key using array syntax"); +if ($loaded_key === false) { + die("failed to load key using array syntax"); +} openssl_pkey_free($loaded_key); @@ -38,8 +43,9 @@ echo "Load key using direct syntax\n"; $loaded_key = openssl_pkey_get_private("file://$key_file_name", $passphrase); -if ($loaded_key === false) - die("failed to load key using direct syntax"); +if ($loaded_key === false) { + die("failed to load key using direct syntax"); +} openssl_pkey_free($loaded_key); @@ -48,15 +54,13 @@ echo "Load key manually and use string syntax\n"; $key_content = file_get_contents($key_file_name); $loaded_key = openssl_pkey_get_private($key_content, $passphrase); -if ($loaded_key === false) - die("failed to load key using string syntax"); - +if ($loaded_key === false) { + die("failed to load key using string syntax"); +} openssl_pkey_free($loaded_key); echo "OK!\n"; -@unlink($key_file_name); - ?> --EXPECT-- Creating private key @@ -66,3 +70,8 @@ Load key from file - array syntax Load key using direct syntax Load key manually and use string syntax OK! +--CLEAN-- +<?php +$key_file_name = __DIR__ . DIRECTORY_SEPARATOR . '001-tmp.key'; +@unlink($key_file_name); +?>
\ No newline at end of file |