Author: mturk Date: Sat Oct 8 07:27:13 2011 New Revision: 1180327 URL: http://svn.apache.org/viewvc?rev=1180327&view=rev Log: Split ssl.c to two files
Added: commons/sandbox/runtime/trunk/src/main/native/modules/openssl/engine.c (with props) Modified: commons/sandbox/runtime/trunk/src/main/native/Makefile.unx.in commons/sandbox/runtime/trunk/src/main/native/modules/openssl/ssl.c 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=1180327&r1=1180326&r2=1180327&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/Makefile.unx.in (original) +++ commons/sandbox/runtime/trunk/src/main/native/Makefile.unx.in Sat Oct 8 07:27:13 2011 @@ -153,6 +153,7 @@ SSLSOURCES=\ $(TOPDIR)/modules/openssl/bio.c \ $(TOPDIR)/modules/openssl/cert.c \ $(TOPDIR)/modules/openssl/ctx.c \ + $(TOPDIR)/modules/openssl/engine.c \ $(TOPDIR)/modules/openssl/init.c \ $(TOPDIR)/modules/openssl/key.c \ $(TOPDIR)/modules/openssl/password.c \ Added: commons/sandbox/runtime/trunk/src/main/native/modules/openssl/engine.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/modules/openssl/engine.c?rev=1180327&view=auto ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/modules/openssl/engine.c (added) +++ commons/sandbox/runtime/trunk/src/main/native/modules/openssl/engine.c Sat Oct 8 07:27:13 2011 @@ -0,0 +1,97 @@ +/* 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/string.h" +#include "acr/port.h" +#include "arch_sync.h" +#include "acr/ssl.h" + +#if !HAVE_OPENSSL +#error "Cannot compile this file without HAVE_OPENSSL defined" +#endif + +#ifndef OPENSSL_NO_ENGINE +/* Try to load an engine in a shareable library */ +static ENGINE *ssl_try_load_engine(const char *engine) +{ + ENGINE *e = ENGINE_by_id("dynamic"); + if (e != 0) { + if (!ENGINE_ctrl_cmd_string(e, "SO_PATH", engine, 0) || + !ENGINE_ctrl_cmd_string(e, "LOAD", 0, 0)) { + ENGINE_free(e); + e = 0; + } + } + return e; +} + +ACR_SSL_EXPORT(jlong, SSLEngine, init0)(JNI_STDARGS, jstring name) +{ + jlong ep = 0; + int rc = 0; + + WITH_CSTR(name) { + ENGINE *ee = 0; + if (strcmp(J2S(name), "auto") == 0) { + ENGINE_register_all_complete(); + } + else { + if ((ee = ENGINE_by_id(J2S(name))) == 0 && + (ee = ssl_try_load_engine(J2S(name))) == 0) + rc = ACR_ENOTIMPL; + else { + if (strcmp(J2S(name), "chil") == 0) + ENGINE_ctrl(ee, ENGINE_CTRL_CHIL_SET_FORKCHECK, 1, 0, 0); + if (!ENGINE_set_default(ee, ENGINE_METHOD_ALL)) { + rc = ACR_ENOTIMPL; + ENGINE_free(ee); + ee = 0; + } + } + if (ee != 0) + ep = P2J(ee); + } + } DONE_WITH_STR(name); + if (rc != 0) + ACR_THROW_SYS_ERROR(rc); + return ep; +} + +ACR_SSL_EXPORT(void, SSLEngine, free0)(JNI_STDARGS, jlong ep) +{ + ENGINE *ee = J2P(ep, ENGINE *); + /* Free our "structural" reference. */ + if (ee != 0) + ENGINE_free(ee); +} + +#else +ACR_SSL_EXPORT(jlong, SSLEngine, init0)(JNI_STDARGS, jstring name) +{ + ACR_THROW_SYS_ERROR(ACR_ENOTIMPL); + return 0; +} + +ACR_SSL_EXPORT(void, SSLEngine, free0)(JNI_STDARGS, jlong ep) +{ +} + +#endif + Propchange: commons/sandbox/runtime/trunk/src/main/native/modules/openssl/engine.c ------------------------------------------------------------------------------ svn:eol-style = native Modified: commons/sandbox/runtime/trunk/src/main/native/modules/openssl/ssl.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/modules/openssl/ssl.c?rev=1180327&r1=1180326&r2=1180327&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/modules/openssl/ssl.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/modules/openssl/ssl.c Sat Oct 8 07:27:13 2011 @@ -32,22 +32,6 @@ #define ACR_SSL_HAS_OCSP_STAPLING 3 #define ACR_SSL_HAS_TLSEXT 4 -#ifndef OPENSSL_NO_ENGINE -/* Try to load an engine in a shareable library */ -static ENGINE *ssl_try_load_engine(const char *engine) -{ - ENGINE *e = ENGINE_by_id("dynamic"); - if (e != 0) { - if (!ENGINE_ctrl_cmd_string(e, "SO_PATH", engine, 0) || - !ENGINE_ctrl_cmd_string(e, "LOAD", 0, 0)) { - ENGINE_free(e); - e = 0; - } - } - return e; -} -#endif - ACR_SSL_EXPORT(jboolean, SSL, has0)(JNI_STDARGS, jint what) { jboolean rv = JNI_FALSE; @@ -96,49 +80,3 @@ ACR_SSL_EXPORT(void, SSL, fipsmode0)(JNI "You will need an OpenSSL with FIPS support."); #endif } - -ACR_SSL_EXPORT(jlong, SSLEngine, init0)(JNI_STDARGS, jstring name) -{ - jlong ep = 0; - int rc = 0; -#ifndef OPENSSL_NO_ENGINE - WITH_CSTR(name) { - ENGINE *ee = 0; - if (strcmp(J2S(name), "auto") == 0) { - ENGINE_register_all_complete(); - } - else { - if ((ee = ENGINE_by_id(J2S(name))) == 0 && - (ee = ssl_try_load_engine(J2S(name))) == 0) - rc = ACR_ENOTIMPL; - else { - if (strcmp(J2S(name), "chil") == 0) - ENGINE_ctrl(ee, ENGINE_CTRL_CHIL_SET_FORKCHECK, 1, 0, 0); - if (!ENGINE_set_default(ee, ENGINE_METHOD_ALL)) { - rc = ACR_ENOTIMPL; - ENGINE_free(ee); - ee = 0; - } - } - if (ee != 0) - ep = P2J(ee); - } - } DONE_WITH_STR(name); -#else - rc = ACR_ENOTIMPL; -#endif - if (rc != 0) - ACR_THROW_SYS_ERROR(rc); - return ep; -} - -ACR_SSL_EXPORT(void, SSLEngine, free0)(JNI_STDARGS, jlong ep) -{ -#ifndef OPENSSL_NO_ENGINE - ENGINE *ee = J2P(ep, ENGINE *); - /* Free our "structural" reference. */ - if (ee != 0) - ENGINE_free(ee); -#endif -} -