pajoye Tue Aug 15 20:27:20 2006 UTC
Modified files: (Branch: PHP_5_2)
/php-src NEWS
/php-src/ext/openssl php_openssl.h openssl.c
Log:
- add openssl_csr_get_subject() and openssl_csr_get_public_key()
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.205&r2=1.2027.2.547.2.206&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.205 php-src/NEWS:1.2027.2.547.2.206
--- php-src/NEWS:1.2027.2.547.2.205 Tue Aug 15 20:13:47 2006
+++ php-src/NEWS Tue Aug 15 20:27:20 2006
@@ -29,6 +29,7 @@
. Added openssl_pkey_get_details, returns the details of a key
. Added x509 v3 extensions support
. Added a new constant OPENSSL_KEYTYPE_EC
+ . Added openssl_csr_get_subject() and openssl_csr_get_public_key()
- Fixed overflow on 64bit systems in str_repeat() and wordwrap(). (Stefan E.)
- Disabled CURLOPT_FOLLOWLOCATION in curl when open_basedir or safe_mode are
http://cvs.php.net/viewvc.cgi/php-src/ext/openssl/php_openssl.h?r1=1.16.2.1.2.1&r2=1.16.2.1.2.2&diff_format=u
Index: php-src/ext/openssl/php_openssl.h
diff -u php-src/ext/openssl/php_openssl.h:1.16.2.1.2.1
php-src/ext/openssl/php_openssl.h:1.16.2.1.2.2
--- php-src/ext/openssl/php_openssl.h:1.16.2.1.2.1 Tue Aug 15 00:38:04 2006
+++ php-src/ext/openssl/php_openssl.h Tue Aug 15 20:27:20 2006
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_openssl.h,v 1.16.2.1.2.1 2006/08/15 00:38:04 pajoye Exp $ */
+/* $Id: php_openssl.h,v 1.16.2.1.2.2 2006/08/15 20:27:20 pajoye Exp $ */
#ifndef PHP_OPENSSL_H
#define PHP_OPENSSL_H
@@ -67,7 +67,8 @@
PHP_FUNCTION(openssl_csr_export);
PHP_FUNCTION(openssl_csr_export_to_file);
PHP_FUNCTION(openssl_csr_sign);
-
+PHP_FUNCTION(openssl_csr_get_subject);
+PHP_FUNCTION(openssl_csr_get_public_key);
#else
#define phpext_openssl_ptr NULL
http://cvs.php.net/viewvc.cgi/php-src/ext/openssl/openssl.c?r1=1.98.2.5.2.10&r2=1.98.2.5.2.11&diff_format=u
Index: php-src/ext/openssl/openssl.c
diff -u php-src/ext/openssl/openssl.c:1.98.2.5.2.10
php-src/ext/openssl/openssl.c:1.98.2.5.2.11
--- php-src/ext/openssl/openssl.c:1.98.2.5.2.10 Tue Aug 15 00:38:04 2006
+++ php-src/ext/openssl/openssl.c Tue Aug 15 20:27:20 2006
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: openssl.c,v 1.98.2.5.2.10 2006/08/15 00:38:04 pajoye Exp $ */
+/* $Id: openssl.c,v 1.98.2.5.2.11 2006/08/15 20:27:20 pajoye Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -113,6 +113,8 @@
PHP_FE(openssl_csr_export, second_arg_force_ref)
PHP_FE(openssl_csr_export_to_file, NULL)
PHP_FE(openssl_csr_sign, NULL)
+ PHP_FE(openssl_csr_get_subject, NULL)
+ PHP_FE(openssl_csr_get_public_key, NULL)
PHP_FE(openssl_sign, second_arg_force_ref)
PHP_FE(openssl_verify, NULL)
@@ -248,9 +250,13 @@
ASN1_STRING * str = NULL;
ASN1_OBJECT * obj;
- MAKE_STD_ZVAL(subitem);
- array_init(subitem);
-
+ if (key != NULL) {
+ MAKE_STD_ZVAL(subitem);
+ array_init(subitem);
+ } else {
+ subitem = val;
+ }
+
for (i = 0; i < X509_NAME_entry_count(name); i++) {
ne = X509_NAME_get_entry(name, i);
obj = X509_NAME_ENTRY_get_object(ne);
@@ -291,7 +297,9 @@
}
}
}
- zend_hash_update(HASH_OF(val), key, strlen(key) + 1, (void *)&subitem,
sizeof(subitem), NULL);
+ if (key != NULL) {
+ zend_hash_update(HASH_OF(val), key, strlen(key) + 1, (void
*)&subitem, sizeof(subitem), NULL);
+ }
}
/* }}} */
@@ -1527,8 +1535,6 @@
}
/* }}} */
-
-
/* {{{ proto bool openssl_csr_export(resource csr, string &out [, bool
notext=true])
Exports a CSR to file or a var */
PHP_FUNCTION(openssl_csr_export)
@@ -1789,6 +1795,61 @@
}
/* }}} */
+/* {{{ proto mixed openssl_csr_get_subject(mixed csr)
+ Returns the subject of a CERT or FALSE on error */
+PHP_FUNCTION(openssl_csr_get_subject)
+{
+ zval * zcsr;
+ zend_bool use_shortnames = 1;
+ long csr_resource;
+ X509_NAME * subject;
+ X509_REQ * csr;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|b", &zcsr,
&use_shortnames) == FAILURE) {
+ return;
+ }
+
+ csr = php_openssl_csr_from_zval(&zcsr, 0, &csr_resource TSRMLS_CC);
+
+ if (csr == NULL) {
+ RETURN_FALSE;
+ }
+
+ subject = X509_REQ_get_subject_name(csr);
+
+ array_init(return_value);
+ add_assoc_name_entry(return_value, NULL, subject, use_shortnames
TSRMLS_CC);
+ return;
+}
+/* }}} */
+
+/* {{{ proto mixed openssl_csr_get_public_key(mixed csr)
+ Returns the subject of a CERT or FALSE on error */
+PHP_FUNCTION(openssl_csr_get_public_key)
+{
+ zval * zcsr;
+ zend_bool use_shortnames = 1;
+ long csr_resource;
+
+ X509_REQ * csr;
+ EVP_PKEY *tpubkey;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|b", &zcsr,
&use_shortnames) == FAILURE) {
+ return;
+ }
+
+ csr = php_openssl_csr_from_zval(&zcsr, 0, &csr_resource TSRMLS_CC);
+
+ if (csr == NULL) {
+ RETURN_FALSE;
+ }
+
+ tpubkey=X509_REQ_get_pubkey(csr);
+ RETVAL_RESOURCE(zend_list_insert(tpubkey, le_key));
+ return;
+}
+/* }}} */
+
/* }}} */
/* {{{ EVP Public/Private key functions */
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php