mturk       2005/06/16 04:39:12

  Modified:    jni/native/include ssl_private.h tcn.h
               jni/native/src jnilib.c ssl.c sslinfo.c
  Log:
  Add more SSL infos.
  Also change the tcn_new_string to allow the NULL to be passed.
  
  Revision  Changes    Path
  1.30      +4 -1      
jakarta-tomcat-connectors/jni/native/include/ssl_private.h
  
  Index: ssl_private.h
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jni/native/include/ssl_private.h,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- ssl_private.h     15 Jun 2005 12:08:02 -0000      1.29
  +++ ssl_private.h     16 Jun 2005 11:39:12 -0000      1.30
  @@ -145,6 +145,9 @@
   #define SSL_INFO_CIPHER             (2)
   #define SSL_INFO_CIPHER_USEKEYSIZE  (3)
   #define SSL_INFO_CIPHER_ALGKEYSIZE  (4)
  +#define SSL_INFO_CIPHER_VERSION     (5)
  +#define SSL_INFO_CIPHER_DESCRIPTION (6)
  +#define SSL_INFO_PROTOCOL           (7)
   
   #define SSL_VERIFY_ERROR_IS_OPTIONAL(errnum) \
      ((errnum == X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT) \
  
  
  
  1.18      +4 -2      jakarta-tomcat-connectors/jni/native/include/tcn.h
  
  Index: tcn.h
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jni/native/include/tcn.h,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- tcn.h     12 Jun 2005 07:01:03 -0000      1.17
  +++ tcn.h     16 Jun 2005 11:39:12 -0000      1.18
  @@ -97,7 +97,9 @@
   void            tcn_Throw(JNIEnv *, const char *, ...);
   void            tcn_ThrowException(JNIEnv *, const char *);
   void            tcn_ThrowAPRException(JNIEnv *, apr_status_t);
  -jstring         tcn_new_string(JNIEnv *, const char *, int);
  +jstring         tcn_new_string(JNIEnv *, const char *);
  +jstring         tcn_new_stringn(JNIEnv *, const char *, size_t);
  +jbyteArray      tcn_new_arrayb(JNIEnv *, const unsigned char *, size_t);
   char           *tcn_get_string(JNIEnv *, jstring);
   char           *tcn_strdup(JNIEnv *, jstring);
   char           *tcn_pstrdup(JNIEnv *, jstring, apr_pool_t *);
  
  
  
  1.10      +23 -3     jakarta-tomcat-connectors/jni/native/src/jnilib.c
  
  Index: jnilib.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jni/native/src/jnilib.c,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- jnilib.c  10 Jun 2005 10:30:18 -0000      1.9
  +++ jnilib.c  16 Jun 2005 11:39:12 -0000      1.10
  @@ -89,12 +89,14 @@
       apr_terminate();
   }
   
  -jstring tcn_new_string(JNIEnv *env, const char *str, int l)
  +jstring tcn_new_stringn(JNIEnv *env, const char *str, size_t l)
   {
       jstring result;
       jbyteArray bytes = 0;
       size_t len = l;
  -
  +    
  +    if (!str)
  +        return NULL;
       if ((*env)->EnsureLocalCapacity(env, 2) < 0) {
           return NULL; /* out of memory error */
       }
  @@ -110,6 +112,24 @@
       return NULL;
   }
   
  +jbyteArray tcn_new_arrayb(JNIEnv *env, const unsigned char *data, size_t len)
  +{
  +    jbyteArray bytes = (*env)->NewByteArray(env, (jsize)len);
  +    if (bytes != NULL) {
  +        (*env)->SetByteArrayRegion(env, bytes, 0, (jint)len, (jbyte *)data);
  +    }
  +    return bytes;
  +}
  +
  +
  +jstring tcn_new_string(JNIEnv *env, const char *str)
  +{
  +    if (!str)
  +        return NULL;
  +    else
  +        return (*env)->NewStringUTF(env, str);
  +}
  +
   char *tcn_get_string(JNIEnv *env, jstring jstr)
   {
       jbyteArray bytes = NULL;
  
  
  
  1.36      +3 -3      jakarta-tomcat-connectors/jni/native/src/ssl.c
  
  Index: ssl.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jni/native/src/ssl.c,v
  retrieving revision 1.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- ssl.c     12 Jun 2005 07:33:08 -0000      1.35
  +++ ssl.c     16 Jun 2005 11:39:12 -0000      1.36
  @@ -599,7 +599,7 @@
           JNIEnv   *e = j->cb.env;
           ret = (*e)->CallIntMethod(e, j->cb.obj,
                                     j->cb.mid[2],
  -                                  tcn_new_string(e, in, -1));
  +                                  tcn_new_string(e, in));
       }
       return ret;
   }
  @@ -775,7 +775,7 @@
       char buf[256];
       UNREFERENCED(o);
       ERR_error_string(ERR_get_error(), buf);
  -    return tcn_new_string(e, buf, -1);
  +    return tcn_new_string(e, buf);
   }
   
   #else
  
  
  
  1.3       +23 -6     jakarta-tomcat-connectors/jni/native/src/sslinfo.c
  
  Index: sslinfo.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jni/native/src/sslinfo.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- sslinfo.c 15 Jun 2005 12:08:02 -0000      1.2
  +++ sslinfo.c 16 Jun 2005 11:39:12 -0000      1.3
  @@ -64,10 +64,8 @@
           {
               SSL_SESSION *session  = SSL_get_session(s->ssl);
               if (session) {
  -                jsize len = (jsize)session->session_id_length;
  -                if ((array = (*e)->NewByteArray(e, len)) != NULL)
  -                    (*e)->SetByteArrayRegion(e, array, 0, len,
  -                                (jbyte *)(&session->session_id[0]));
  +                array = tcn_new_arrayb(e, &session->session_id[0],
  +                                       session->session_id_length); 
               }
           }
           break;
  @@ -96,12 +94,31 @@
                   char *hs = convert_to_hex(&session->session_id[0],
                                             session->session_id_length);
                   if (hs) {
  -                    value = tcn_new_string(e, hs, -1);
  +                    value = tcn_new_string(e, hs);
                       free(hs);
                   }
               }
           }
           break;
  +        case SSL_INFO_PROTOCOL:
  +            value = tcn_new_string(e, SSL_get_version(s->ssl));
  +        break;
  +        case SSL_INFO_CIPHER:
  +            value = tcn_new_string(e, SSL_get_cipher_name(s->ssl));
  +        break;
  +        case SSL_INFO_CIPHER_VERSION:
  +            value = tcn_new_string(e, SSL_get_cipher_version(s->ssl));
  +        break;
  +        case SSL_INFO_CIPHER_DESCRIPTION:
  +            {
  +                SSL_CIPHER *cipher = SSL_get_current_cipher(s->ssl);
  +                if (cipher) {
  +                    char buf[256];
  +                    char *desc = SSL_CIPHER_description(cipher, buf, 256);
  +                    value = tcn_new_string(e, desc);
  +                }
  +            }
  +        break;
           default:
               tcn_ThrowAPRException(e, APR_EINVAL);
           break;
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to