rrichards Sat Jan 20 22:08:29 2007 UTC
Added files: (Branch: PHP_5_2)
/php-src/ext/openssl/tests 005.phpt
Modified files:
/php-src/ext/openssl openssl.c
/php-src/ext/openssl/tests bug38261.phpt
Log:
MFH: fix accessing public key from x509 resource
add test
fix test under win32
http://cvs.php.net/viewvc.cgi/php-src/ext/openssl/openssl.c?r1=1.98.2.5.2.26&r2=1.98.2.5.2.27&diff_format=u
Index: php-src/ext/openssl/openssl.c
diff -u php-src/ext/openssl/openssl.c:1.98.2.5.2.26
php-src/ext/openssl/openssl.c:1.98.2.5.2.27
--- php-src/ext/openssl/openssl.c:1.98.2.5.2.26 Sun Jan 7 18:38:21 2007
+++ php-src/ext/openssl/openssl.c Sat Jan 20 22:08:29 2007
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: openssl.c,v 1.98.2.5.2.26 2007/01/07 18:38:21 iliaa Exp $ */
+/* $Id: openssl.c,v 1.98.2.5.2.27 2007/01/20 22:08:29 rrichards Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -1958,10 +1958,10 @@
/* got the key - return it */
return (EVP_PKEY*)what;
}
+ } else {
+ /* other types could be used here - eg: file pointers
and read in the data from them */
+ TMP_CLEAN;
}
-
- /* other types could be used here - eg: file pointers and read
in the data from them */
- TMP_CLEAN;
} else {
/* force it to be a string and check if it refers to a file */
/* passing non string values leaks, object uses toString, it
returns NULL
http://cvs.php.net/viewvc.cgi/php-src/ext/openssl/tests/bug38261.phpt?r1=1.1.2.1&r2=1.1.2.2&diff_format=u
Index: php-src/ext/openssl/tests/bug38261.phpt
diff -u php-src/ext/openssl/tests/bug38261.phpt:1.1.2.1
php-src/ext/openssl/tests/bug38261.phpt:1.1.2.2
--- php-src/ext/openssl/tests/bug38261.phpt:1.1.2.1 Sun Jul 30 16:26:19 2006
+++ php-src/ext/openssl/tests/bug38261.phpt Sat Jan 20 22:08:29 2007
@@ -27,8 +27,8 @@
bool(false)
bool(false)
-Warning: openssl_x509_parse() expects at least 1 parameter, 0 given in
%s/bug38261.php on line %d
+Warning: openssl_x509_parse() expects at least 1 parameter, 0 given in
%sbug38261.php on line %d
NULL
bool(false)
-Catchable fatal error: Object of class stdClass could not be converted to
string in %s/bug38261.php on line %d
+Catchable fatal error: Object of class stdClass could not be converted to
string in %sbug38261.php on line %d
http://cvs.php.net/viewvc.cgi/php-src/ext/openssl/tests/005.phpt?view=markup&rev=1.1
Index: php-src/ext/openssl/tests/005.phpt
+++ php-src/ext/openssl/tests/005.phpt
--TEST--
openSSL: read public key from x.509 resource
--SKIPIF--
<?php
if (!extension_loaded("openssl")) die("skip");
?>
--FILE--
<?php
$dir = dirname(__FILE__);
$file_pub = $dir . '/bug37820cert.pem';
$file_key = $dir . '/bug37820key.pem';
$priv_key = file_get_contents($file_key);
$priv_key_id = openssl_get_privatekey($priv_key);
$x509 = openssl_x509_read(file_get_contents($file_pub));
$pub_key_id = openssl_get_publickey($x509);
$data = "some custom data";
if (!openssl_sign($data, $signature, $priv_key_id, OPENSSL_ALGO_MD5)) {
echo "openssl_sign failed.";
}
$ok = openssl_verify($data, $signature, $pub_key_id, OPENSSL_ALGO_MD5);
if ($ok == 1) {
echo "Ok";
} elseif ($ok == 0) {
echo "openssl_verify failed.";
}
?>
--EXPECTF--
Ok
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php