tony2001 Thu Apr 5 07:24:21 2007 UTC Modified files: /php-src/ext/openssl openssl.c php_openssl.h /php-src/ext/openssl/tests 005.phpt Log: fix build & test improve coding style http://cvs.php.net/viewvc.cgi/php-src/ext/openssl/openssl.c?r1=1.135&r2=1.136&diff_format=u Index: php-src/ext/openssl/openssl.c diff -u php-src/ext/openssl/openssl.c:1.135 php-src/ext/openssl/openssl.c:1.136 --- php-src/ext/openssl/openssl.c:1.135 Wed Apr 4 21:39:01 2007 +++ php-src/ext/openssl/openssl.c Thu Apr 5 07:24:21 2007 @@ -20,7 +20,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: openssl.c,v 1.135 2007/04/04 21:39:01 pajoye Exp $ */ +/* $Id: openssl.c,v 1.136 2007/04/05 07:24:21 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -44,6 +44,7 @@ #include <openssl/conf.h> #include <openssl/rand.h> #include <openssl/ssl.h> +#include <openssl/pkcs12.h> #define DEFAULT_KEY_LENGTH 512 #define MIN_KEY_LENGTH 384 @@ -1308,7 +1309,7 @@ /* {{{ x509 CSR functions */ -static void php_sk_X509_free(STACK_OF(X509) * sk) +static void php_sk_X509_free(STACK_OF(X509) * sk) /* {{{ */ { for (;;) { X509* x = sk_X509_pop(sk); @@ -1317,8 +1318,9 @@ } sk_X509_free(sk); } +/* }}} */ -static STACK_OF(X509) * php_array_to_X509_sk(zval ** zcerts) +static STACK_OF(X509) * php_array_to_X509_sk(zval ** zcerts TSRMLS_DC) /* {{{ */ { HashPosition hpos; zval ** zcertval; @@ -1370,6 +1372,7 @@ clean_exit: return sk; } +/* }}} */ /* {{{ proto bool openssl_pkcs12_export_to_file(mixed x509, string filename, mixed priv_key, string pass[, array args]) Creates and exports a PKCS to file */ @@ -1389,8 +1392,9 @@ zval ** item; STACK_OF(X509) *ca = NULL; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zszs|a", &zcert, &filename, &filename_len, &zpkey, &pass, &pass_len, &args) == FAILURE) + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zszs|a", &zcert, &filename, &filename_len, &zpkey, &pass, &pass_len, &args) == FAILURE) { return; + } RETVAL_FALSE; @@ -1408,21 +1412,23 @@ php_error_docref(NULL TSRMLS_CC, E_WARNING, "private key does not correspond to cert"); goto cleanup; } - if (php_openssl_safe_mode_chk(filename TSRMLS_CC)) { + if (php_check_open_basedir(filename TSRMLS_CC)) { goto cleanup; } /* parse extra config from args array, promote this to an extra function */ - if (args && zend_hash_find(Z_ARRVAL_P(args), "friendly_name", sizeof("friendly_name"), (void**)&item) == SUCCESS) + if (args && zend_hash_find(Z_ARRVAL_P(args), "friendly_name", sizeof("friendly_name"), (void**)&item) == SUCCESS) { friendly_name = Z_STRVAL_PP(item); + } /* certpbe (default RC2-40) keypbe (default 3DES) friendly_caname */ - if (args && zend_hash_find(Z_ARRVAL_P(args), "extracerts", sizeof("extracerts"), (void**)&item) == SUCCESS) - ca = php_array_to_X509_sk(item); + if (args && zend_hash_find(Z_ARRVAL_P(args), "extracerts", sizeof("extracerts"), (void**)&item) == SUCCESS) { + ca = php_array_to_X509_sk(item TSRMLS_CC); + } /* end parse extra config */ /* @@ -1473,8 +1479,9 @@ zval ** item; STACK_OF(X509) *ca = NULL; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zzzs|a", &zcert, &zout, &zpkey, &pass, &pass_len, &args) == FAILURE) + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zzzs|a", &zcert, &zout, &zpkey, &pass, &pass_len, &args) == FAILURE) { return; + } RETVAL_FALSE; @@ -1494,11 +1501,13 @@ } /* parse extra config from args array, promote this to an extra function */ - if (args && zend_hash_find(Z_ARRVAL_P(args), "friendly_name", sizeof("friendly_name"), (void**)&item) == SUCCESS) + if (args && zend_hash_find(Z_ARRVAL_P(args), "friendly_name", sizeof("friendly_name"), (void**)&item) == SUCCESS) { friendly_name = Z_STRVAL_PP(item); + } - if (args && zend_hash_find(Z_ARRVAL_P(args), "extracerts", sizeof("extracerts"), (void**)&item) == SUCCESS) - ca = php_array_to_X509_sk(item); + if (args && zend_hash_find(Z_ARRVAL_P(args), "extracerts", sizeof("extracerts"), (void**)&item) == SUCCESS) { + ca = php_array_to_X509_sk(item TSRMLS_CC); + } /* end parse extra config */ p12 = PKCS12_create(pass, friendly_name, priv_key, cert, ca, 0, 0, 0, 0, 0); @@ -1543,8 +1552,9 @@ BIO * bio_in = NULL; int i; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zzs", &zp12, &zout, &pass, &pass_len) == FAILURE) + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zzs", &zp12, &zout, &pass, &pass_len) == FAILURE) { return; + } RETVAL_FALSE; @@ -1628,6 +1638,8 @@ } /* }}} */ +/* }}} */ + /* {{{ x509 CSR functions */ /* {{{ php_openssl_make_REQ */ @@ -1931,8 +1943,9 @@ int i; struct php_x509_request req; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ZZ!Zl|a!l", &zcsr, &zcert, &zpkey, &num_days, &args, &serial) == FAILURE) + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ZZ!Zl|a!l", &zcsr, &zcert, &zpkey, &num_days, &args, &serial) == FAILURE) { return; + } RETVAL_FALSE; PHP_SSL_REQ_INIT(&req); http://cvs.php.net/viewvc.cgi/php-src/ext/openssl/php_openssl.h?r1=1.19&r2=1.20&diff_format=u Index: php-src/ext/openssl/php_openssl.h diff -u php-src/ext/openssl/php_openssl.h:1.19 php-src/ext/openssl/php_openssl.h:1.20 --- php-src/ext/openssl/php_openssl.h:1.19 Mon Jan 1 09:29:26 2007 +++ php-src/ext/openssl/php_openssl.h Thu Apr 5 07:24:21 2007 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_openssl.h,v 1.19 2007/01/01 09:29:26 sebastian Exp $ */ +/* $Id: php_openssl.h,v 1.20 2007/04/05 07:24:21 tony2001 Exp $ */ #ifndef PHP_OPENSSL_H #define PHP_OPENSSL_H @@ -63,6 +63,11 @@ PHP_FUNCTION(openssl_x509_export); PHP_FUNCTION(openssl_x509_export_to_file); PHP_FUNCTION(openssl_x509_check_private_key); + +PHP_FUNCTION(openssl_pkcs12_export); +PHP_FUNCTION(openssl_pkcs12_export_to_file); +PHP_FUNCTION(openssl_pkcs12_read); + PHP_FUNCTION(openssl_csr_new); PHP_FUNCTION(openssl_csr_export); PHP_FUNCTION(openssl_csr_export_to_file); http://cvs.php.net/viewvc.cgi/php-src/ext/openssl/tests/005.phpt?r1=1.2&r2=1.3&diff_format=u Index: php-src/ext/openssl/tests/005.phpt diff -u php-src/ext/openssl/tests/005.phpt:1.2 php-src/ext/openssl/tests/005.phpt:1.3 --- php-src/ext/openssl/tests/005.phpt:1.2 Wed Apr 4 21:39:01 2007 +++ php-src/ext/openssl/tests/005.phpt Thu Apr 5 07:24:21 2007 @@ -1,7 +1,10 @@ --TEST-- openssl_csr_get_subject() tests --SKIPIF-- -<?php if (!extension_loaded("openssl")) print "skip"; ?> +<?php +if (!extension_loaded("openssl")) die("skip"); +if (!function_exists("utf8_decode")) die("skip"); +?> --FILE-- <?php
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php