cvs: php4(PHP_4_2_0) /ext/openssl openssl.c /ext/openssl/tests .cvsignore 001.phpt skipif.inc
| From: | Derick Rethans | Date: | Tue, 26 Mar 2002 07:39:59 +0000 |
| Subject: | cvs: php4(PHP_4_2_0) /ext/openssl openssl.c /ext/openssl/tests .cvsignore 001.phpt skipif.inc | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-10687@lists.php.net to get a copy of this message | ||
derick Tue Mar 26 02:39:59 2002 EDT
Added files: (Branch: PHP_4_2_0)
/php4/ext/openssl/tests .cvsignore 001.phpt skipif.inc
Modified files:
/php4/ext/openssl openssl.c
Log:
- MFH for passphrase bug
Index: php4/ext/openssl/openssl.c
diff -u php4/ext/openssl/openssl.c:1.41 php4/ext/openssl/openssl.c:1.41.2.1
--- php4/ext/openssl/openssl.c:1.41 Thu Feb 28 03:26:30 2002
+++ php4/ext/openssl/openssl.c Tue Mar 26 02:39:58 2002
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: openssl.c,v 1.41 2002/02/28 08:26:30 sebastian Exp $ */
+/* $Id: openssl.c,v 1.41.2.1 2002/03/26 07:39:58 derick Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -140,6 +140,9 @@
static void php_pkey_free(zend_rsrc_list_entry *rsrc TSRMLS_DC)
{
EVP_PKEY *pkey = (EVP_PKEY *)rsrc->ptr;
+
+ assert(pkey != NULL);
+
EVP_PKEY_free(pkey);
}
@@ -1684,7 +1687,7 @@
X509_free(cert);
if (key && makeresource && resourceval) {
- *resourceval = zend_list_insert(key, le_key);
+ *resourceval = ZEND_REGISTER_RESOURCE(NULL, key, le_key);
}
return key;
}
@@ -1911,7 +1914,7 @@
return;
Z_TYPE_P(return_value) = IS_RESOURCE;
- pkey = php_openssl_evp_from_zval(&cert, 0, NULL, 1, &Z_LVAL_P(return_value) TSRMLS_CC);
+ pkey = php_openssl_evp_from_zval(&cert, 0, passphrase, 1, &Z_LVAL_P(return_value)
TSRMLS_CC);
if (pkey == NULL) {
RETURN_FALSE;
Index: php4/ext/openssl/tests/.cvsignore
+++ php4/ext/openssl/tests/.cvsignore
*.exp
*.out
*.php
phpt.*
Index: php4/ext/openssl/tests/001.phpt
+++ php4/ext/openssl/tests/001.phpt
--TEST--
OpenSSL private key functions
--SKIPIF--
<?php include('skipif.inc'); ?>
--POST--
--GET--
--FILE--
<?php
echo "Creating private key\n";
$privkey = openssl_pkey_new();
if ($privkey === false)
die("failed to create private key");
$passphrase = "banana";
$key_file_name = tempnam("/tmp", "ssl");
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) or die("failed to export to
file $key_file_name");
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");
openssl_pkey_free($loaded_key);
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");
openssl_pkey_free($loaded_key);
echo "Load key manually and use string syntax\n";
$fp = fopen($key_file_name, "r");
$key_content = fread($fp, filesize($key_file_name));
fclose($fp);
$loaded_key = openssl_pkey_get_private($key_content, $passphrase);
if ($loaded_key === false)
die("failed to load key using string syntax");
openssl_pkey_free($loaded_key);
echo "OK!\n";
?>
--EXPECT--
Creating private key
Export key to file
Load key from file - array syntax
Load key using direct syntax
Load key manually and use string syntax
OK!
Index: php4/ext/openssl/tests/skipif.inc
+++ php4/ext/openssl/tests/skipif.inc
<?php
// This script prints "skip" if condition does not meet.
if (!extension_loaded("openssl") && ini_get("enable_dl")) {
$dlext = (substr(PHP_OS, 0, 3) == "WIN") ? ".dll" : ".so";
@dl("openssl$dlext");
}
if (!extension_loaded("openssl")) {
die("skip\n");
}
?>