commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r1187746 - in /commons/sandbox/runtime/trunk/src/main: java/org/apache/commons/runtime/ssl/SSLContext.java java/org/apache/commons/runtime/ssl/SSLServer.java native/modules/openssl/ctx.c native/modules/openssl/server.c
Date Sat, 22 Oct 2011 18:46:43 GMT
Author: mturk
Date: Sat Oct 22 18:46:42 2011
New Revision: 1187746

URL: http://svn.apache.org/viewvc?rev=1187746&view=rev
Log:
Set ciphers and fix setContext

Modified:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/SSLContext.java
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/SSLServer.java
    commons/sandbox/runtime/trunk/src/main/native/modules/openssl/ctx.c
    commons/sandbox/runtime/trunk/src/main/native/modules/openssl/server.c

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/SSLContext.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/SSLContext.java?rev=1187746&r1=1187745&r2=1187746&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/SSLContext.java
(original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/SSLContext.java
Sat Oct 22 18:46:42 2011
@@ -44,7 +44,8 @@ public final class SSLContext extends SS
         throws OperationNotImplementedException;
     private static native void    free0(long key);
     private static native void    setsprefix0(long ctx, String prefix);
-    private static native void    setciphers0(long ctx, String prefix);
+    private static native void    setciphers0(long ctx, String prefix)
+        throws SSLException;
     private static native void    setid0(long ctx, String id);
     private static native void    setscachesize0(long ctx, int size);
     private static native void    setcrlcheck0(long ctx, int mode);
@@ -169,7 +170,8 @@ public final class SSLContext extends SS
 
     public synchronized void setCipherSuite(String ciphers)
         throws InvalidArgumentException,
-               ObjectNotInitializedException
+               ObjectNotInitializedException,
+               SSLException
     {
         if (super.pointer == 0L)
             throw new ObjectNotInitializedException();

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/SSLServer.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/SSLServer.java?rev=1187746&r1=1187745&r2=1187746&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/SSLServer.java
(original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/SSLServer.java
Sat Oct 22 18:46:42 2011
@@ -41,7 +41,10 @@ public final class SSLServer extends SSL
         throws OutOfMemoryError;
     private static native void    close0(long srv);
     private static native void    setbio0(long srv, long bio);
-    private static native void    setctx0(long srv, long ctx);
+    private static native void    setctx0(long srv, long ctx)
+        throws SSLException;
+    private static native void    setctx2(long srv, long ctx)
+        throws SSLException;
     private static native void    setservname0(long src, String name);
 
     private static native void    setoption0(long srv, int opt, boolean on);
@@ -133,14 +136,39 @@ public final class SSLServer extends SSL
      * @throws ClosedObjectException if server is closed.
      */
     public synchronized final SSLContext setContext(SSLContext ctx)
-        throws IllegalStateException
+        throws IllegalStateException,
+               SSLException
     {
         if (super.pointer == 0L)
             throw new ClosedObjectException();
-        SSLContext org = ctx1;
-        ctx1 = ctx;
+        if (ctx1 != null)
+            return ctx1;
         setctx0(super.pointer, ((SSLObject)ctx).pointer);
-        return org;
+        ctx1 = ctx;
+        return null;
+    }
+
+    /**
+     * Set this server's TLSExt SSL context.
+     * <p>
+     *
+     * </p>
+     * @param ctx the context to set
+     * @return previous context or {@code null} if the context
+     *          was not set already.
+     * @throws ClosedObjectException if server is closed.
+     */
+    public synchronized final SSLContext setTLSExtContext(SSLContext ctx)
+        throws IllegalStateException,
+               SSLException
+    {
+        if (super.pointer == 0L)
+            throw new ClosedObjectException();
+        if (ctx2 != null)
+            return ctx2;
+        setctx2(super.pointer, ((SSLObject)ctx).pointer);
+        ctx2 = ctx;
+        return null;
     }
 
     /**

Modified: commons/sandbox/runtime/trunk/src/main/native/modules/openssl/ctx.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/modules/openssl/ctx.c?rev=1187746&r1=1187745&r2=1187746&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/modules/openssl/ctx.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/modules/openssl/ctx.c Sat Oct 22 18:46:42
2011
@@ -374,6 +374,8 @@ ACR_SSL_EXPORT(void, SSLContext, setciph
 {    
     acr_ssl_ctx_t *c = J2P(ctx, acr_ssl_ctx_t *);    
     SET_CTX_STRING(c->cipher_suite, val);
+    if (c->cipher_suite != 0 && !SSL_CTX_set_cipher_list(c->ctx, c->cipher_suite))
+        ssl_throw_errno(env, ACR_EX_ESSL);
 }
 
 ACR_SSL_EXPORT(void, SSLContext, addcastore0)(JNI_STDARGS, jlong ctx,

Modified: commons/sandbox/runtime/trunk/src/main/native/modules/openssl/server.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/modules/openssl/server.c?rev=1187746&r1=1187745&r2=1187746&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/modules/openssl/server.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/modules/openssl/server.c Sat Oct 22 18:46:42
2011
@@ -92,11 +92,18 @@ ACR_SSL_EXPORT(void, SSLServer, setctx2)
 {
     acr_ssl_srv_t *s = J2P(srv, acr_ssl_srv_t *);
     acr_ssl_ctx_t *c = J2P(ctx, acr_ssl_ctx_t *);
-
+    
     if (ssl_ctx_retain(c) != 0) {
         s->ctx2 = c;
         if (s->options != 0)
             SSL_CTX_set_options(c->ctx, s->options);
+        if (c->cipher_suite == 0 && s->ctx != 0 && s->ctx->cipher_suite
!= 0) {
+            if (!SSL_CTX_set_cipher_list(c->ctx, s->ctx->cipher_suite)) {
+                ssl_throw_errno(env, ACR_EX_ESSL);
+                ssl_ctx_release(c);
+                s->ctx2 = 0;
+            }
+        }
     }
 }
 



Mime
View raw message