From: Wez Furlong Date: Tue, 26 Mar 2002 00:03:11 +0000 (+0000) Subject: Fix regular openssl_pkey_get_private($content, $phrase) syntax and X-Git-Tag: php-4.3.0dev-ZendEngine2-Preview1~1040 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=74749ad642989c0ab31ac99ce9d9c3724696f7fe;p=php Fix regular openssl_pkey_get_private($content, $phrase) syntax and add test case. This stuff should be merged into the 4.2 branch. --- diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c index fb95b14cfd..e3d92a4ec9 100644 --- a/ext/openssl/openssl.c +++ b/ext/openssl/openssl.c @@ -140,6 +140,9 @@ static int le_csr; 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 @@ static EVP_PKEY * php_openssl_evp_from_zval(zval ** val, int public_key, char * 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 @@ PHP_FUNCTION(openssl_pkey_get_private) 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; diff --git a/ext/openssl/tests/001.phpt b/ext/openssl/tests/001.phpt new file mode 100644 index 0000000000..06a9c04bf5 --- /dev/null +++ b/ext/openssl/tests/001.phpt @@ -0,0 +1,64 @@ +--TEST-- +OpenSSL private key functions +--SKIPIF-- + +--POST-- +--GET-- +--FILE-- + +--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! diff --git a/ext/openssl/tests/skipif.inc b/ext/openssl/tests/skipif.inc new file mode 100644 index 0000000000..21e947d0b2 --- /dev/null +++ b/ext/openssl/tests/skipif.inc @@ -0,0 +1,11 @@ +