commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r1159678 - in /commons/sandbox/runtime/trunk/src/main: java/org/apache/commons/runtime/ java/org/apache/commons/runtime/io/ native/ native/include/acr/ native/srclib/openssl/ test/org/apache/commons/runtime/
Date Fri, 19 Aug 2011 16:33:34 GMT
Author: mturk
Date: Fri Aug 19 16:33:34 2011
New Revision: 1159678

URL: http://svn.apache.org/viewvc?rev=1159678&view=rev
Log:
Start work on OpenSSL support

Added:
    commons/sandbox/runtime/trunk/src/main/native/include/acr/ssl.h   (with props)
    commons/sandbox/runtime/trunk/src/main/native/srclib/openssl/
    commons/sandbox/runtime/trunk/src/main/native/srclib/openssl/api.c   (with props)
Modified:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Native.java
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/MemoryStream.java
    commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in
    commons/sandbox/runtime/trunk/src/main/native/Makefile.unx.in
    commons/sandbox/runtime/trunk/src/main/native/configure.bat
    commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestMain.java

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Native.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Native.java?rev=1159678&r1=1159677&r2=1159678&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Native.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Native.java Fri
Aug 19 16:33:34 2011
@@ -34,6 +34,8 @@ public final class Native
         throws Throwable;
     private static native boolean isdbg0();
     private static native boolean hasopenssl0();
+    private static native boolean ldopenssl0()
+        throws RuntimeException;
     private static native void    fini0();
 
     /**
@@ -91,4 +93,18 @@ public final class Native
         }
     }
 
+    private static boolean sslresolved = false;
+    /**
+     * Load OpenSSL libraries
+     */
+    public static synchronized boolean ldopenssl()
+        throws RuntimeException
+    {
+        if (sslresolved)
+            return true;
+        if (HAS_OPENSSL)
+            sslresolved = ldopenssl0();
+        return sslresolved;
+    }
+
 }

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/MemoryStream.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/MemoryStream.java?rev=1159678&r1=1159677&r2=1159678&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/MemoryStream.java
(original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/MemoryStream.java
Fri Aug 19 16:33:34 2011
@@ -22,6 +22,7 @@ import java.io.IOException;
 import java.io.SyncFailedException;
 import java.nio.ByteBuffer;
 import org.apache.commons.runtime.InvalidArgumentException;
+import org.apache.commons.runtime.InvalidRangeException;
 import org.apache.commons.runtime.Pointer;
 import org.apache.commons.runtime.OverflowException;
 import org.apache.commons.runtime.util.Utils;

Modified: commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in?rev=1159678&r1=1159677&r2=1159678&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in (original)
+++ commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in Fri Aug 19 16:33:34 2011
@@ -21,6 +21,7 @@ SRCDIRS=\
 	$(TOPDIR)\port \
 	$(TOPDIR)\shared \
 	$(TOPDIR)\srclib\bzip2 \
+	$(TOPDIR)\srclib\openssl \
 	$(TOPDIR)\srclib\zlib \
 	$(TOPDIR)\srclib\zlib\win32
 
@@ -148,10 +149,14 @@ LIBSOURCES=\
 	$(TOPDIR)\shared\version.c \
 	$(TOPDIR)\shared\buildmark.c
 
+SSLSOURCES=\
+	$(TOPDIR)\srclib\openssl\api.c
+
 CXXSOURCES=
 
 DEPOBJECTS=$(LIBSOURCES:.c=.dep)
 SHROBJECTS=$(LIBSOURCES:.c=.obj) $(ASMSOURCES:.asm=.obj) $(TOPDIR)\os\win32\main.res
+SSLOBJECTS=$(SSLSOURCES:.c=.$(SLO))
 
 all : prepare $(SHAREDDLL)
 
@@ -169,7 +174,7 @@ all : prepare $(SHAREDDLL)
 .c.dep:
 	@mkdepend $*.$$(OBJ) $(CCFLAGS) $(CCSHARE) $(CPPOPTS) $(CFLAGS) $(INCLUDES) $< >>Makedeps
 
-$(SHAREDDLL): $(SHROBJECTS)
+$(SHAREDDLL): $(SHROBJECTS) $(MODULES)
 	@echo Building shared library ...
 	$(LD) /DLL $(LDFLAGS) /SUBSYSTEM:WINDOWS $(LDARCH) /pdb:$(OUTLIBDIR)\$(DLLNAME).pdb /OUT:$@
@<<
 	$(SHROBJECTS) $(MODULES) $(LIBS)

Modified: commons/sandbox/runtime/trunk/src/main/native/Makefile.unx.in
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/Makefile.unx.in?rev=1159678&r1=1159677&r2=1159678&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/Makefile.unx.in (original)
+++ commons/sandbox/runtime/trunk/src/main/native/Makefile.unx.in Fri Aug 19 16:33:34 2011
@@ -24,6 +24,7 @@ SRCDIRS=\
 	$(TOPDIR)/port \
 	$(TOPDIR)/shared \
 	$(TOPDIR)/srclib/bzip2 \
+	$(TOPDIR)/srclib/openssl \
 	$(TOPDIR)/srclib/zlib \
 	$(TOPDIR)/srclib/zlib/unix
 
@@ -143,9 +144,13 @@ LIBSOURCES=\
 	$(TOPDIR)/shared/version.c \
 	$(TOPDIR)/shared/buildmark.c
 
+SSLSOURCES=\
+	$(TOPDIR)/srclib/openssl/api.c
+
 CXXSOURCES=
 
 SHROBJECTS=$(LIBSOURCES:.c=.$(SLO)) $(CXXSOURCES:.cc=.$(SLO)) $(ASMSOURCES:.S=.$(SLO))
+SSLOBJECTS=$(SSLSOURCES:.c=.$(SLO))
 
 all: prepare @sharedlib@ @modules@
 

Modified: commons/sandbox/runtime/trunk/src/main/native/configure.bat
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/configure.bat?rev=1159678&r1=1159677&r2=1159678&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/configure.bat (original)
+++ commons/sandbox/runtime/trunk/src/main/native/configure.bat Fri Aug 19 16:33:34 2011
@@ -99,6 +99,7 @@ set ENABLE_DEBUG=0
 set HAVE_OPENSSL=0
 set HAVE_INTRIN_H=0
 set WITH_OPENSSL=
+set MODULES=
 
 :ParseOption
 set "OPTION=%~1"
@@ -148,6 +149,7 @@ if %HAVE_OPENSSL% == 1 (
      echo.
   )
   set "INCLUDES=%INCLUDES% -I%WITH_OPENSSL%"
+  set "MODULES=$(SSLOBJECTS)"
 )
 
 if not exist "%WITH_JAVA%\include\jni.h" (

Added: commons/sandbox/runtime/trunk/src/main/native/include/acr/ssl.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr/ssl.h?rev=1159678&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr/ssl.h (added)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr/ssl.h Fri Aug 19 16:33:34 2011
@@ -0,0 +1,249 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _ACR_SSL_H_
+#define _ACR_SSL_H_
+
+#include "acr/stdtypes.h"
+#if HAVE_OPENSSL
+
+/* Exclude unused OpenSSL features
+ * even if the OpenSSL supports them
+ */
+#ifndef OPENSSL_NO_IDEA
+#define OPENSSL_NO_IDEA
+#endif
+#ifndef OPENSSL_NO_KRB5
+#define OPENSSL_NO_KRB5
+#endif
+#ifndef OPENSSL_NO_MDC2
+#define OPENSSL_NO_MDC2
+#endif
+#ifndef OPENSSL_NO_RC5
+#define OPENSSL_NO_RC5
+#endif
+
+/* OpenSSL headers */
+#include <openssl/ssl.h>
+#include <openssl/err.h>
+#include <openssl/x509.h>
+#include <openssl/pem.h>
+#include <openssl/crypto.h>
+#include <openssl/evp.h>
+#include <openssl/rand.h>
+#include <openssl/x509v3.h>
+#include <openssl/md5.h>
+/* Avoid tripping over an engine build installed globally and detected
+ * when the user points at an explicit non-engine flavor of OpenSSL
+ */
+#ifndef OPENSSL_NO_ENGINE
+#include <openssl/engine.h>
+#endif
+
+#ifndef RAND_MAX
+#include <limits.h>
+#define RAND_MAX INT_MAX
+#endif
+
+#define SSL_ALGO_UNKNOWN (0)
+#define SSL_ALGO_RSA     (1<<0)
+#define SSL_ALGO_DSA     (1<<1)
+#define SSL_ALGO_ALL     (SSL_ALGO_RSA|SSL_ALGO_DSA)
+
+#define SSL_AIDX_RSA     (0)
+#define SSL_AIDX_DSA     (1)
+#define SSL_AIDX_MAX     (2)
+
+/*
+ * Define IDs for the temporary RSA keys and DH params
+ */
+
+#define SSL_TMP_KEY_RSA_512     (0)
+#define SSL_TMP_KEY_RSA_1024    (1)
+#define SSL_TMP_KEY_RSA_2048    (2)
+#define SSL_TMP_KEY_RSA_4096    (3)
+#define SSL_TMP_KEY_DH_512      (4)
+#define SSL_TMP_KEY_DH_1024     (5)
+#define SSL_TMP_KEY_DH_2048     (6)
+#define SSL_TMP_KEY_DH_4096     (7)
+#define SSL_TMP_KEY_MAX         (8)
+
+#define SSL_CRT_FORMAT_UNDEF    (0)
+#define SSL_CRT_FORMAT_ASN1     (1)
+#define SSL_CRT_FORMAT_TEXT     (2)
+#define SSL_CRT_FORMAT_PEM      (3)
+#define SSL_CRT_FORMAT_NETSCAPE (4)
+#define SSL_CRT_FORMAT_PKCS12   (5)
+#define SSL_CRT_FORMAT_SMIME    (6)
+#define SSL_CRT_FORMAT_ENGINE   (7)
+/* XXX this stupid macro helps us to avoid
+ * adding yet another param to load_*key()
+ */
+#define SSL_KEY_FORMAT_IISSGC   (8)
+
+/*
+ * Define the SSL options
+ */
+#define SSL_OPT_NONE            (0)
+#define SSL_OPT_RELSET          (1<<0)
+#define SSL_OPT_STDENVVARS      (1<<1)
+#define SSL_OPT_EXPORTCERTDATA  (1<<3)
+#define SSL_OPT_FAKEBASICAUTH   (1<<4)
+#define SSL_OPT_STRICTREQUIRE   (1<<5)
+#define SSL_OPT_OPTRENEGOTIATE  (1<<6)
+#define SSL_OPT_ALL             (SSL_OPT_STDENVVARS|SSL_OPT_EXPORTCERTDATA|SSL_OPT_FAKEBASICAUTH|SSL_OPT_STRICTREQUIRE|SSL_OPT_OPTRENEGOTIATE)
+
+/*
+ * Define the SSL Protocol options
+ */
+#define SSL_PROTOCOL_NONE       (0)
+#define SSL_PROTOCOL_SSLV2      (1<<0)
+#define SSL_PROTOCOL_SSLV3      (1<<1)
+#define SSL_PROTOCOL_TLSV1      (1<<2)
+#define SSL_PROTOCOL_ALL        (SSL_PROTOCOL_SSLV2|SSL_PROTOCOL_SSLV3|SSL_PROTOCOL_TLSV1)
+
+#define SSL_MODE_CLIENT         (0)
+#define SSL_MODE_SERVER         (1)
+#define SSL_MODE_COMBINED       (2)
+
+#define SSL_BIO_FLAG_RDONLY     (1<<0)
+#define SSL_BIO_FLAG_CALLBACK   (1<<1)
+#define SSL_DEFAULT_CACHE_SIZE  (256)
+#define SSL_MAX_STR_LEN         (2048)
+#define SSL_MAX_PASSWORD_LEN    (256)
+
+#define SSL_CVERIFY_UNSET           (-1)
+#define SSL_CVERIFY_NONE            (0)
+#define SSL_CVERIFY_OPTIONAL        (1)
+#define SSL_CVERIFY_REQUIRE         (2)
+#define SSL_CVERIFY_OPTIONAL_NO_CA  (3)
+#define SSL_VERIFY_PEER_STRICT      (SSL_VERIFY_PEER|SSL_VERIFY_FAIL_IF_NO_PEER_CERT)
+
+#define SSL_SHUTDOWN_TYPE_UNSET     (0)
+#define SSL_SHUTDOWN_TYPE_STANDARD  (1)
+#define SSL_SHUTDOWN_TYPE_UNCLEAN   (2)
+#define SSL_SHUTDOWN_TYPE_ACCURATE  (3)
+
+#define SSL_TO_APR_ERROR(X)         (APR_OS_START_USERERR + 1000 + X)
+
+#define SSL_INFO_SESSION_ID                 (0x0001)
+#define SSL_INFO_CIPHER                     (0x0002)
+#define SSL_INFO_CIPHER_USEKEYSIZE          (0x0003)
+#define SSL_INFO_CIPHER_ALGKEYSIZE          (0x0004)
+#define SSL_INFO_CIPHER_VERSION             (0x0005)
+#define SSL_INFO_CIPHER_DESCRIPTION         (0x0006)
+#define SSL_INFO_PROTOCOL                   (0x0007)
+
+#define SSL_INFO_CLIENT_S_DN                (0x0010)
+#define SSL_INFO_CLIENT_I_DN                (0x0020)
+#define SSL_INFO_SERVER_S_DN                (0x0040)
+#define SSL_INFO_SERVER_I_DN                (0x0080)
+
+#define SSL_INFO_DN_COUNTRYNAME             (0x0001)
+#define SSL_INFO_DN_STATEORPROVINCENAME     (0x0002)
+#define SSL_INFO_DN_LOCALITYNAME            (0x0003)
+#define SSL_INFO_DN_ORGANIZATIONNAME        (0x0004)
+#define SSL_INFO_DN_ORGANIZATIONALUNITNAME  (0x0005)
+#define SSL_INFO_DN_COMMONNAME              (0x0006)
+#define SSL_INFO_DN_TITLE                   (0x0007)
+#define SSL_INFO_DN_INITIALS                (0x0008)
+#define SSL_INFO_DN_GIVENNAME               (0x0009)
+#define SSL_INFO_DN_SURNAME                 (0x000A)
+#define SSL_INFO_DN_DESCRIPTION             (0x000B)
+#define SSL_INFO_DN_UNIQUEIDENTIFIER        (0x000C)
+#define SSL_INFO_DN_EMAILADDRESS            (0x000D)
+
+#define SSL_INFO_CLIENT_MASK                (0x0100)
+
+#define SSL_INFO_CLIENT_M_VERSION           (0x0101)
+#define SSL_INFO_CLIENT_M_SERIAL            (0x0102)
+#define SSL_INFO_CLIENT_V_START             (0x0103)
+#define SSL_INFO_CLIENT_V_END               (0x0104)
+#define SSL_INFO_CLIENT_A_SIG               (0x0105)
+#define SSL_INFO_CLIENT_A_KEY               (0x0106)
+#define SSL_INFO_CLIENT_CERT                (0x0107)
+#define SSL_INFO_CLIENT_V_REMAIN            (0x0108)
+
+#define SSL_INFO_SERVER_MASK                (0x0200)
+
+#define SSL_INFO_SERVER_M_VERSION           (0x0201)
+#define SSL_INFO_SERVER_M_SERIAL            (0x0202)
+#define SSL_INFO_SERVER_V_START             (0x0203)
+#define SSL_INFO_SERVER_V_END               (0x0204)
+#define SSL_INFO_SERVER_A_SIG               (0x0205)
+#define SSL_INFO_SERVER_A_KEY               (0x0206)
+#define SSL_INFO_SERVER_CERT                (0x0207)
+#define SSL_INFO_CLIENT_CERT_CHAIN          (0x0400)
+
+#define SSL_VERIFY_ERROR_IS_OPTIONAL(errnum) \
+   ((errnum == X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT) \
+    || (errnum == X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN) \
+    || (errnum == X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY) \
+    || (errnum == X509_V_ERR_CERT_UNTRUSTED) \
+    || (errnum == X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE))
+
+#define SSL_DEFAULT_PASS_PROMPT "Some of your private key files are encrypted for security
reasons.\n"  \
+                                "In order to read them you have to provide the pass phrases.\n"
        \
+                                "Enter password :"
+
+extern void *SSL_temp_keys[SSL_TMP_KEY_MAX];
+
+typedef struct ssl_pkc_t {
+    /* client can have any number of cert/key pairs */
+    const char  *cert_file;
+    const char  *cert_path;
+    STACK_OF(X509_INFO) *certs;
+} ssl_pkc_t;
+
+typedef struct acr_ssl_ctxt_t {
+    SSL_CTX         *ctx;
+    BIO             *bio_os;
+    BIO             *bio_is;
+
+    unsigned char   context_id[MD5_DIGEST_LENGTH];
+
+    int             protocol;
+    /* we are one or the other */
+    int             mode;
+
+    /* certificate revocation list */
+    X509_STORE      *crl;
+    /* pointer to the context verify store */
+    X509_STORE      *store;
+    const char      *cert_files[SSL_AIDX_MAX];
+    const char      *key_files[SSL_AIDX_MAX];
+    X509            *certs[SSL_AIDX_MAX];
+    EVP_PKEY        *keys[SSL_AIDX_MAX];
+
+    int             ca_certs;
+    int             shutdown_type;
+    char            *rand_file;
+
+    const char      *cipher_suite;
+    /* for client or downstream server authentication */
+    int             verify_depth;
+    int             verify_mode;
+} acr_ssl_ctxt_t;
+
+#define SSL_CTX_get_extra_certs(ctx)        ((ctx)->extra_certs)
+#define SSL_CTX_set_extra_certs(ctx, value) \
+    do {                                    \
+        (ctx)->extra_certs = (value);       \
+    } while (0)
+
+
+#endif
+#endif /* _ACR_SSL_H_ */

Propchange: commons/sandbox/runtime/trunk/src/main/native/include/acr/ssl.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/runtime/trunk/src/main/native/srclib/openssl/api.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/srclib/openssl/api.c?rev=1159678&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/srclib/openssl/api.c (added)
+++ commons/sandbox/runtime/trunk/src/main/native/srclib/openssl/api.c Fri Aug 19 16:33:34
2011
@@ -0,0 +1,124 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "acr/clazz.h"
+#include "acr/error.h"
+#include "acr/misc.h"
+#include "acr/dso.h"
+#include "acr/ssl.h"
+
+#if !HAVE_OPENSSL
+#error "Cannot compile this file without HAVE_OPENSSL defined"
+#endif
+
+#if defined(WINDOWS)
+#define SSL_DSO_NAME       L"ssleay32.dll"
+#define CRYPTO_DSO_NAME    L"libeay32.dll"
+#else
+#define SSL_DSO_NAME       "libssl" PACKAGE_DLLEXT
+#define CRYPTO_DSO_NAME    "libcrypto" PACKAGE_DLLEXT
+#endif
+
+#if HAVE_OPENSSL_STATIC
+
+ACR_JNI_EXPORT(jboolean, Native, ldopenssl0)(JNI_STDARGS)
+{
+    return JNI_TRUE;
+}
+
+#else /* !HAVE_OPENSSL_STATIC */
+/**
+ * Dynamic OpenSSL API loader
+ */
+
+#define LIBSSL_FPLOAD(fN)                                       \
+    fname  = #fN;                                               \
+    SSLapi.fp##fN = AcrGetProcAddress(ssldso, fname);           \
+    if (SSLapi.fp##fN == 0) goto failed
+
+#define CRYPTO_FPLOAD(fN)                                       \
+    fname  = #fN;                                               \
+    SSLapi.fp##fN = AcrGetProcAddress(cryptodso, fname);        \
+    if (SSLapi.fp##fN == 0) goto failed
+
+#define SSLAPI_LINK(fN) (*SSLapi.fp##fN)
+
+struct SSLAPIst {
+    unsigned long       (*fpSSLeay)(void);
+    const char*         (*fpSSLeay_version)(int);
+
+    SSL_CTX*            (*fpSSL_CTX_new)(const SSL_METHOD *);
+    void                (*fpSSL_CTX_free)(SSL_CTX *);
+
+};
+
+static struct SSLAPIst SSLapi;
+static acr_dso_t       ssldso;
+static acr_dso_t       cryptodso;
+
+ACR_JNI_EXPORT(jboolean, Native, ldopenssl0)(JNI_STDARGS)
+{
+    char b[512];
+    const char *fname = "";
+    const char *dname = SSL_DSO_NAME;
+
+    if ((cryptodso = AcrDsoLoad(CRYPTO_DSO_NAME)) == 0) {
+        ACR_THROW_SYS_ERRNO();
+        return JNI_FALSE;
+    }
+    if ((ssldso = AcrDsoLoad(SSL_DSO_NAME)) == 0) {
+        ACR_THROW_SYS_ERRNO();
+        return JNI_FALSE;
+    }    
+    LIBSSL_FPLOAD(SSLeay);
+    LIBSSL_FPLOAD(SSLeay_version);
+    if (0x00908000L > SSLAPI_LINK(SSLeay)()) {
+        AcrThrow(env, ACR_EX_ERUNTIME,
+                 "OpenSSL 0.9.8 or greater is required");
+        return JNI_FALSE;
+    }
+    LIBSSL_FPLOAD(SSL_CTX_new);
+    LIBSSL_FPLOAD(SSL_CTX_free);
+    
+    return JNI_TRUE;
+failed:
+    snprintf(b, sizeof(b), "Cannot find %s#%s", dname, fname);
+    AcrThrow(env, ACR_EX_ENOENT, b);
+    return JNI_FALSE;
+}
+
+/* === OpenSSL wrappers for dynamic functions === */
+unsigned long SSLeay()
+{
+    return SSLAPI_LINK(SSLeay)();
+}
+
+const char *SSLeay_version(int type)
+{
+    return SSLAPI_LINK(SSLeay_version)(type);
+}
+
+SSL_CTX *SSL_CTX_new(const SSL_METHOD *meth)
+{
+    return SSLAPI_LINK(SSL_CTX_new)(meth);
+}
+
+void SSL_CTX_free(SSL_CTX *ctx)
+{
+    SSLAPI_LINK(SSL_CTX_free)(ctx);
+}
+
+#endif /* HAVE_OPENSSL_STATIC */

Propchange: commons/sandbox/runtime/trunk/src/main/native/srclib/openssl/api.c
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestMain.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestMain.java?rev=1159678&r1=1159677&r2=1159678&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestMain.java (original)
+++ commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestMain.java Fri
Aug 19 16:33:34 2011
@@ -39,6 +39,9 @@ public class TestMain extends Assert
         System.out.print(", Debug=" + Native.HAS_MAINTAINER_MODE);
         System.out.println(".");
         System.out.flush();
+        if (Native.HAS_OPENSSL) {
+            assertTrue(Native.ldopenssl());
+        }
     }
     
     @AfterSuite(groups = { "init" })



Mime
View raw message