wez             Sun Apr  1 18:31:07 2001 EDT

  Modified files:              
    /php4/ext/openssl   openssl.c 
  Log:
  added some more error reporting and did a little tidying.
  
  
Index: php4/ext/openssl/openssl.c
diff -u php4/ext/openssl/openssl.c:1.10 php4/ext/openssl/openssl.c:1.11
--- php4/ext/openssl/openssl.c:1.10     Sun Apr  1 16:06:14 2001
+++ php4/ext/openssl/openssl.c  Sun Apr  1 18:31:07 2001
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: openssl.c,v 1.10 2001/04/01 23:06:14 wez Exp $ */
+/* $Id: openssl.c,v 1.11 2001/04/02 01:31:07 wez Exp $ */
 
 #include "php.h"
 #include "php_openssl.h"
@@ -152,7 +152,7 @@
        if (resourceval)
                *resourceval = -1;
 
-       if ((*val)->type == IS_RESOURCE)        {
+       if (Z_TYPE_PP(val) == IS_RESOURCE)      {
                /* is it an x509 resource ? */
                void * what;
                int type;
@@ -210,7 +210,7 @@
 /* Given a zval, coerce it into a EVP_PKEY object.
        It can be:
                1. private key resource from openssl_get_privatekey()
-               2. X509 resource -> private key will be extracted from it
+               2. X509 resource -> public key will be extracted from it
                3. if it starts with file:// interpreted as path to key file
                4. interpreted as the data from the cert/key file and interpreted in 
same way as openssl_get_privatekey()
                5. an array(0 => [items 2..4], 1 => passphrase)
@@ -225,13 +225,13 @@
        int free_cert = 0;
        long cert_res = -1;
        char * filename = NULL;
-
+       
        if (resourceval)
                *resourceval = -1;
 
-       if ((*val)->type == IS_ARRAY)   {
+       if (Z_TYPE_PP(val) == IS_ARRAY) {
                zval ** zphrase;
-
+               
                /* get passphrase */
 
                if (zend_hash_index_find(HASH_OF(*val), 1, (void **)&zphrase) == 
FAILURE)       {
@@ -248,7 +248,7 @@
                }
        }
 
-       if ((*val)->type == IS_RESOURCE)        {
+       if (Z_TYPE_PP(val) == IS_RESOURCE)      {
                void * what;
                int type;
 
@@ -1144,20 +1144,28 @@
        convert_to_string_ex(zoutfilename);
 
        privkey = php_openssl_evp_from_zval(zprivkey, 0, "", 0, &keyresource);
-       if (privkey == NULL)
+       if (privkey == NULL)    {
+               zend_error(E_ERROR, "%s(): error getting private key", 
+get_active_function_name());
                goto clean_exit;
+       }
 
        cert = php_openssl_x509_from_zval(zcert, 0, &certresource);
-       if (cert == NULL)
+       if (cert == NULL)       {
+               zend_error(E_ERROR, "%s(): error getting cert", 
+get_active_function_name());
                goto clean_exit;
+       }
 
        infile = BIO_new_file(Z_STRVAL_PP(zinfilename), "r");
-       if (infile == NULL)
+       if (infile == NULL)     {
+               zend_error(E_ERROR, "%s(): error opening input file %s!", 
+get_active_function_name(), Z_STRVAL_PP(zinfilename));
                goto clean_exit;
+       }
 
        outfile = BIO_new_file(Z_STRVAL_PP(zoutfilename), "w");
-       if (outfile == NULL)
+       if (outfile == NULL)    {
+               zend_error(E_ERROR, "%s(): error opening output file %s!", 
+get_active_function_name(), Z_STRVAL_PP(zoutfilename));
                goto clean_exit;
+       }
 
        p7 = PKCS7_sign(cert, privkey, others, infile, flags);
        if (p7 == NULL) {



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to