Re: cvs: php4 /ext/openssl openssl.c /ext/openssl/tests .cvsignore 001.phpt skipif.inc
| From: | derick@php.net | Date: | Wed, 03 Apr 2002 07:51:22 +0000 |
| Subject: | Re: cvs: php4 /ext/openssl openssl.c /ext/openssl/tests .cvsignore 001.phpt skipif.inc | ||
| References: | 1 | Groups: | php.qa |
| Request: | Send a blank email to php-qa+get-4849@lists.php.net to get a copy of this message | ||
On Tue, 26 Mar 2002, Wez Furlong wrote:
> Hi Derick,
>
> Sorry to keep pushing these on you: this is essentially a single word
> fix (around line 1915 of openssl.c) that should make it into 4.2.
> The test case is "optional", but shouldn't hurt either.
>
> Could you merge it?
I can, but you can do it too if you want, including the test.
Derick
> On 26/03/02, "Wez Furlong" <wez.php@thebrainroom.com> wrote:
> > wez Mon Mar 25 19:03:09 2002 EDT
> >
> > Added files:
> > /php4/ext/openssl/tests .cvsignore 001.phpt skipif.inc
> >
> > Modified files:
> > /php4/ext/openssl openssl.c
> > Log:
> > Fix regular openssl_pkey_get_private($content, $phrase) syntax and
> > add test case.
> > This stuff should be merged into the 4.2 branch.
> >
> >
> > Index: php4/ext/openssl/openssl.c
> > diff -u php4/ext/openssl/openssl.c:1.41 php4/ext/openssl/openssl.c:1.42
> > --- php4/ext/openssl/openssl.c:1.41 Thu Feb 28 03:26:30 2002
> > +++ php4/ext/openssl/openssl.c Mon Mar 25 19:03:08 2002
> > @@ -18,7 +18,7 @@
> > +----------------------------------------------------------------------+
> > */
> >
> > -/* $Id: openssl.c,v 1.41 2002/02/28 08:26:30 sebastian Exp $ */
> > +/* $Id: openssl.c,v 1.42 2002/03/26 00:03:08 wez 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");
> > }
> > ?>
> >
> >
> >
> > --
> > PHP CVS Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
-----------------------------------------------------------------------
PHP: Scripting the Web - derick@php.net
All your branches are belong to me!
SRM: Script Running Machine - www.vl-srm.net
-----------------------------------------------------------------------