wez Tue Sep 23 12:05:51 2003 EDT
Modified files:
/php-src/ext/openssl openssl.c
/php-src/ext/openssl/tests bug25614.phpt
Log:
MFB 25614 "fix"
Index: php-src/ext/openssl/openssl.c
diff -u php-src/ext/openssl/openssl.c:1.81 php-src/ext/openssl/openssl.c:1.82
--- php-src/ext/openssl/openssl.c:1.81 Sun Aug 31 16:45:42 2003
+++ php-src/ext/openssl/openssl.c Tue Sep 23 12:05:50 2003
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: openssl.c,v 1.81 2003/08/31 20:45:42 iliaa Exp $ */
+/* $Id: openssl.c,v 1.82 2003/09/23 16:05:50 wez Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -1738,14 +1738,23 @@
cert = (X509*)what;
free_cert = 0;
} else if (type == le_key) {
+ int is_priv;
+
+ is_priv = php_openssl_is_private_key((EVP_PKEY*)what
TSRMLS_CC);
+
/* check whether it is actually a private key if requested */
- if (!public_key && !php_openssl_is_private_key((EVP_PKEY*)what
TSRMLS_CC)) {
+ if (!public_key && !ispriv) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "supplied
key param is a public key");
return NULL;
}
-
- /* got the key - return it */
- return (EVP_PKEY*)what;
+
+ if (public_key && is_priv) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Don't
know how to get public key from this private key");
+ return NULL;
+ } else {
+ /* got the key - return it */
+ return (EVP_PKEY*)what;
+ }
}
/* other types could be used here - eg: file pointers and read in the
data from them */
Index: php-src/ext/openssl/tests/bug25614.phpt
diff -u /dev/null php-src/ext/openssl/tests/bug25614.phpt:1.2
--- /dev/null Tue Sep 23 12:05:51 2003
+++ php-src/ext/openssl/tests/bug25614.phpt Tue Sep 23 12:05:51 2003
@@ -0,0 +1,11 @@
+--TEST--
+openssl: get public key from generated private key
+--SKIPIF--
+<?php if (!extension_loaded("openssl")) print "skip"; ?>
+--FILE--
+<?php
+$priv = openssl_pkey_new();
+$pub = openssl_pkey_get_public($priv);
+?>
+--EXPECTF--
+Warning: openssl_pkey_get_public(): Don't know how to get public key from this
private key (the documentation lied) %s
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php