You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by is...@apache.org on 2018/12/10 13:00:51 UTC
[2/2] ignite git commit: IGNITE-8626: Added OpenSSL 1.1 support for
C++
IGNITE-8626: Added OpenSSL 1.1 support for C++
This closes #5590
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/4c48ae0a
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/4c48ae0a
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/4c48ae0a
Branch: refs/heads/master
Commit: 4c48ae0ad29c6ce33868e7394041480da255771b
Parents: 36a1ae0
Author: Igor Sapego <is...@apache.org>
Authored: Mon Dec 10 15:58:14 2018 +0300
Committer: Igor Sapego <is...@apache.org>
Committed: Mon Dec 10 16:00:27 2018 +0300
----------------------------------------------------------------------
.../cpp/common/include/ignite/common/utils.h | 56 ++
modules/platforms/cpp/odbc/Makefile.am | 3 +-
modules/platforms/cpp/odbc/include/Makefile.am | 2 +-
.../cpp/odbc/include/ignite/odbc/ssl/ssl_api.h | 32 +
.../odbc/include/ignite/odbc/ssl/ssl_bindings.h | 357 -----------
.../odbc/include/ignite/odbc/ssl/ssl_gateway.h | 117 +++-
.../platforms/cpp/odbc/project/vs/odbc.vcxproj | 3 +-
.../cpp/odbc/project/vs/odbc.vcxproj.filters | 9 +-
modules/platforms/cpp/odbc/src/connection.cpp | 4 +-
.../cpp/odbc/src/ssl/secure_socket_client.cpp | 158 ++---
modules/platforms/cpp/odbc/src/ssl/ssl_api.cpp | 33 +
.../platforms/cpp/odbc/src/ssl/ssl_gateway.cpp | 639 ++++++++++++++++---
.../cpp/thin-client-test/src/ssl_test.cpp | 2 +-
modules/platforms/cpp/thin-client/Makefile.am | 1 +
.../thin-client/project/vs/thin-client.vcxproj | 5 +-
.../project/vs/thin-client.vcxproj.filters | 11 +-
.../cpp/thin-client/src/impl/data_channel.cpp | 4 +-
.../src/impl/ssl/secure_socket_client.cpp | 139 ++--
.../cpp/thin-client/src/impl/ssl/ssl_api.cpp | 36 ++
.../cpp/thin-client/src/impl/ssl/ssl_api.h | 36 ++
.../cpp/thin-client/src/impl/ssl/ssl_bindings.h | 360 -----------
.../thin-client/src/impl/ssl/ssl_gateway.cpp | 632 +++++++++++++++---
.../cpp/thin-client/src/impl/ssl/ssl_gateway.h | 120 ++++
23 files changed, 1718 insertions(+), 1041 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/4c48ae0a/modules/platforms/cpp/common/include/ignite/common/utils.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/include/ignite/common/utils.h b/modules/platforms/cpp/common/include/ignite/common/utils.h
index 29e36f5..cbcc10c 100644
--- a/modules/platforms/cpp/common/include/ignite/common/utils.h
+++ b/modules/platforms/cpp/common/include/ignite/common/utils.h
@@ -549,6 +549,62 @@ namespace ignite
}
/**
+ * Method guard class template.
+ *
+ * Upon destruction calls provided method on provided class instance.
+ *
+ * @tparam T Value type.
+ */
+ template<typename T>
+ class MethodGuard
+ {
+ public:
+ /** Value type. */
+ typedef T ValueType;
+
+ /** Mehtod type. */
+ typedef void (ValueType::*MethodType)();
+
+ /**
+ * Constructor.
+ *
+ * @param val Instance, to call method on.
+ * @param method Method to call.
+ */
+ MethodGuard(ValueType* val, MethodType method) :
+ val(val),
+ method(method)
+ {
+ // No-op.
+ }
+
+ /**
+ * Destructor.
+ */
+ ~MethodGuard()
+ {
+ if (val && method)
+ (val->*method)();
+ }
+
+ /**
+ * Release control over object.
+ */
+ void Release()
+ {
+ val = 0;
+ method = 0;
+ }
+
+ private:
+ /** Instance, to call method on. */
+ ValueType* val;
+
+ /** Method to call. */
+ MethodType method;
+ };
+
+ /**
* Get dynamic library full name.
* @param name Name without extension.
* @return Full name.
http://git-wip-us.apache.org/repos/asf/ignite/blob/4c48ae0a/modules/platforms/cpp/odbc/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/Makefile.am b/modules/platforms/cpp/odbc/Makefile.am
index 5a8ed6d..5230a2c 100644
--- a/modules/platforms/cpp/odbc/Makefile.am
+++ b/modules/platforms/cpp/odbc/Makefile.am
@@ -57,7 +57,7 @@ libignite_odbc_la_SOURCES = \
src/config/config_tools.cpp \
src/config/configuration.cpp \
src/config/connection_info.cpp \
- src/config/connection_string_parser.cpp \
+ src/config/connection_string_parser.cpp \
src/connection.cpp \
src/cursor.cpp \
src/diagnostic/diagnosable_adapter.cpp \
@@ -81,6 +81,7 @@ libignite_odbc_la_SOURCES = \
src/ssl/ssl_gateway.cpp \
src/ssl/secure_socket_client.cpp \
src/ssl/ssl_mode.cpp \
+ src/ssl/ssl_api.cpp \
src/sql/sql_lexer.cpp \
src/sql/sql_parser.cpp \
src/sql/sql_set_streaming_command.cpp \
http://git-wip-us.apache.org/repos/asf/ignite/blob/4c48ae0a/modules/platforms/cpp/odbc/include/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/Makefile.am b/modules/platforms/cpp/odbc/include/Makefile.am
index be6e059..a3f6995 100644
--- a/modules/platforms/cpp/odbc/include/Makefile.am
+++ b/modules/platforms/cpp/odbc/include/Makefile.am
@@ -53,7 +53,7 @@ noinst_HEADERS = \
ignite/odbc/diagnostic/diagnosable.h \
ignite/odbc/diagnostic/diagnosable_adapter.h \
ignite/odbc/ssl/ssl_mode.h \
- ignite/odbc/ssl/ssl_bindings.h \
+ ignite/odbc/ssl/ssl_api.h \
ignite/odbc/ssl/secure_socket_client.h \
ignite/odbc/ssl/ssl_gateway.h \
ignite/odbc/sql/sql_command.h \
http://git-wip-us.apache.org/repos/asf/ignite/blob/4c48ae0a/modules/platforms/cpp/odbc/include/ignite/odbc/ssl/ssl_api.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/ssl/ssl_api.h b/modules/platforms/cpp/odbc/include/ignite/odbc/ssl/ssl_api.h
new file mode 100644
index 0000000..69c7ab5
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/ssl/ssl_api.h
@@ -0,0 +1,32 @@
+/*
+ * 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 _IGNITE_ODBC_SSL_SSL_API
+#define _IGNITE_ODBC_SSL_SSL_API
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace ssl
+ {
+ bool EnsureSslLoaded();
+ }
+ }
+}
+
+#endif //_IGNITE_ODBC_SSL_SSL_API
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/4c48ae0a/modules/platforms/cpp/odbc/include/ignite/odbc/ssl/ssl_bindings.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/ssl/ssl_bindings.h b/modules/platforms/cpp/odbc/include/ignite/odbc/ssl/ssl_bindings.h
deleted file mode 100644
index 9a1740d..0000000
--- a/modules/platforms/cpp/odbc/include/ignite/odbc/ssl/ssl_bindings.h
+++ /dev/null
@@ -1,357 +0,0 @@
-/*
- * 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 _IGNITE_ODBC_SSL_SSL_BINDINGS
-#define _IGNITE_ODBC_SSL_SSL_BINDINGS
-
-#include <openssl/ssl.h>
-#include <openssl/conf.h>
-#include <openssl/err.h>
-
-#include "ignite/odbc/ssl/ssl_gateway.h"
-
-namespace ignite
-{
- namespace odbc
- {
- namespace ssl
- {
- // Declaring constant used by OpenSSL for readability.
- enum { OPERATION_SUCCESS = 1 };
-
- inline SSL_CTX *SSL_CTX_new(const SSL_METHOD *meth)
- {
- typedef SSL_CTX*(FuncType)(const SSL_METHOD*);
-
- FuncType* fp = reinterpret_cast<FuncType*>(SslGateway::GetInstance().GetFunctions().fpSSL_CTX_new);
-
- return fp(meth);
- }
-
- inline void SSL_CTX_free(SSL_CTX *ctx)
- {
- typedef void(FuncType)(SSL_CTX*);
-
- FuncType* fp = reinterpret_cast<FuncType*>(SslGateway::GetInstance().GetFunctions().fpSSL_CTX_free);
-
- fp(ctx);
- }
-
- inline void SSL_CTX_set_verify(SSL_CTX *ctx, int mode, int(*callback) (int, X509_STORE_CTX *))
- {
- typedef void(FuncType)(SSL_CTX*, int, int(*)(int, X509_STORE_CTX*));
-
- FuncType* fp = reinterpret_cast<FuncType*>(
- SslGateway::GetInstance().GetFunctions().fpSSL_CTX_set_verify);
-
- fp(ctx, mode, callback);
- }
-
- inline void SSL_CTX_set_verify_depth(SSL_CTX *ctx, int depth)
- {
- typedef void(FuncType)(SSL_CTX*, int);
-
- FuncType* fp = reinterpret_cast<FuncType*>(
- SslGateway::GetInstance().GetFunctions().fpSSL_CTX_set_verify_depth);
-
- fp(ctx, depth);
- }
-
- inline int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *cAfile, const char *cApath)
- {
- typedef int(FuncType)(SSL_CTX*, const char*, const char*);
-
- FuncType* fp = reinterpret_cast<FuncType*>(
- SslGateway::GetInstance().GetFunctions().fpSSL_CTX_load_verify_locations);
-
- return fp(ctx, cAfile, cApath);
- }
-
- inline int SSL_CTX_use_certificate_chain_file(SSL_CTX *ctx, const char *file)
- {
- typedef int(FuncType)(SSL_CTX*, const char*);
-
- FuncType* fp = reinterpret_cast<FuncType*>(
- SslGateway::GetInstance().GetFunctions().fpSSL_CTX_use_certificate_chain_file);
-
- return fp(ctx, file);
- }
-
- inline int SSL_CTX_use_RSAPrivateKey_file(SSL_CTX *ctx, const char *file, int type)
- {
- typedef int(FuncType)(SSL_CTX*, const char*, int);
-
- FuncType* fp = reinterpret_cast<FuncType*>(
- SslGateway::GetInstance().GetFunctions().fpSSL_CTX_use_RSAPrivateKey_file);
-
- return fp(ctx, file, type);
- }
-
- inline int SSL_CTX_set_cipher_list(SSL_CTX *ctx, const char *str)
- {
- typedef int(FuncType)(SSL_CTX*, const char*);
-
- FuncType* fp = reinterpret_cast<FuncType*>(
- SslGateway::GetInstance().GetFunctions().fpSSL_CTX_set_cipher_list);
-
- return fp(ctx, str);
- }
-
- inline long SSL_CTX_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg)
- {
- typedef long(FuncType)(SSL_CTX*, int, long, void*);
-
- FuncType* fp = reinterpret_cast<FuncType*>(SslGateway::GetInstance().GetFunctions().fpSSL_CTX_ctrl);
-
- return fp(ctx, cmd, larg, parg);
- }
-
- inline long SSL_get_verify_result(const SSL *s)
- {
- typedef long(FuncType)(const SSL*);
-
- FuncType* fp = reinterpret_cast<FuncType*>(
- SslGateway::GetInstance().GetFunctions().fpSSL_get_verify_result);
-
- return fp(s);
- }
-
- inline int SSL_library_init()
- {
- typedef int(FuncType)();
-
- FuncType* fp = reinterpret_cast<FuncType*>(SslGateway::GetInstance().GetFunctions().fpSSL_library_init);
-
- return fp();
- }
-
- inline void SSL_load_error_strings()
- {
- typedef void(FuncType)();
-
- FuncType* fp = reinterpret_cast<FuncType*>(
- SslGateway::GetInstance().GetFunctions().fpSSL_load_error_strings);
-
- fp();
- }
-
- inline X509 *SSL_get_peer_certificate(const SSL *s)
- {
- typedef X509*(FuncType)(const SSL*);
-
- FuncType* fp = reinterpret_cast<FuncType*>(
- SslGateway::GetInstance().GetFunctions().fpSSL_get_peer_certificate);
-
- return fp(s);
- }
-
- inline long SSL_ctrl(SSL *s, int cmd, long larg, void *parg)
- {
- typedef long(FuncType)(SSL*, int, long, void*);
-
- FuncType* fp = reinterpret_cast<FuncType*>(SslGateway::GetInstance().GetFunctions().fpSSL_ctrl);
-
- return fp(s, cmd, larg ,parg);
- }
-
- inline long SSL_set_tlsext_host_name_(SSL *s, const char *name)
- {
- return ssl::SSL_ctrl(s, SSL_CTRL_SET_TLSEXT_HOSTNAME,
- TLSEXT_NAMETYPE_host_name, const_cast<char*>(name));
- }
-
- inline void SSL_set_connect_state_(SSL* s)
- {
- typedef void(FuncType)(SSL*);
-
- FuncType* fp = reinterpret_cast<FuncType*>(
- SslGateway::GetInstance().GetFunctions().fpSSL_set_connect_state);
-
- return fp(s);
- }
-
- inline int SSL_connect_(SSL* s)
- {
- typedef int(FuncType)(SSL*);
-
- FuncType* fp = reinterpret_cast<FuncType*>(SslGateway::GetInstance().GetFunctions().fpSSL_connect);
-
- return fp(s);
- }
-
- inline int SSL_get_error_(const SSL *s, int ret)
- {
- typedef int(FuncType)(const SSL*, int);
-
- FuncType* fp = reinterpret_cast<FuncType*>(SslGateway::GetInstance().GetFunctions().fpSSL_get_error);
-
- return fp(s, ret);
- }
-
- inline int SSL_want_(const SSL *s)
- {
- typedef int(FuncType)(const SSL*);
-
- FuncType* fp = reinterpret_cast<FuncType*>(SslGateway::GetInstance().GetFunctions().fpSSL_want);
-
- return fp(s);
- }
-
- inline int SSL_write_(SSL *s, const void *buf, int num)
- {
- typedef int(FuncType)(SSL*, const void*, int);
-
- FuncType* fp = reinterpret_cast<FuncType*>(SslGateway::GetInstance().GetFunctions().fpSSL_write);
-
- return fp(s, buf, num);
- }
-
- inline int SSL_read_(SSL *s, void *buf, int num)
- {
- typedef int(FuncType)(SSL*, void*, int);
-
- FuncType* fp = reinterpret_cast<FuncType*>(SslGateway::GetInstance().GetFunctions().fpSSL_read);
-
- return fp(s, buf, num);
- }
-
- inline int SSL_pending_(const SSL *ssl)
- {
- typedef int(FuncType)(const SSL*);
-
- FuncType* fp = reinterpret_cast<FuncType*>(SslGateway::GetInstance().GetFunctions().fpSSL_pending);
-
- return fp(ssl);
- }
-
- inline int SSL_get_fd_(const SSL *ssl)
- {
- typedef int(FuncType)(const SSL*);
-
- FuncType* fp = reinterpret_cast<FuncType*>(SslGateway::GetInstance().GetFunctions().fpSSL_get_fd);
-
- return fp(ssl);
- }
-
- inline void SSL_free_(SSL *ssl)
- {
- typedef void(FuncType)(SSL*);
-
- FuncType* fp = reinterpret_cast<FuncType*>(SslGateway::GetInstance().GetFunctions().fpSSL_free);
-
- fp(ssl);
- }
-
- inline const SSL_METHOD *SSLv23_client_method_()
- {
- typedef const SSL_METHOD*(FuncType)();
-
- FuncType* fp = reinterpret_cast<FuncType*>(
- SslGateway::GetInstance().GetFunctions().fpSSLv23_client_method);
-
- return fp();
- }
-
- inline void OPENSSL_config(const char *configName)
- {
- typedef void(FuncType)(const char*);
-
- FuncType* fp = reinterpret_cast<FuncType*>(SslGateway::GetInstance().GetFunctions().fpOPENSSL_config);
-
- fp(configName);
- }
-
- inline void X509_free(X509 *a)
- {
- typedef void(FuncType)(X509*);
-
- FuncType* fp = reinterpret_cast<FuncType*>(SslGateway::GetInstance().GetFunctions().fpX509_free);
-
- fp(a);
- }
-
- inline BIO *BIO_new_ssl_connect(SSL_CTX *ctx)
- {
- typedef BIO*(FuncType)(SSL_CTX*);
-
- FuncType* fp = reinterpret_cast<FuncType*>(
- SslGateway::GetInstance().GetFunctions().fpBIO_new_ssl_connect);
-
- return fp(ctx);
- }
-
- inline void BIO_free_all(BIO *a)
- {
- typedef void(FuncType)(BIO*);
-
- FuncType* fp = reinterpret_cast<FuncType*>(SslGateway::GetInstance().GetFunctions().fpBIO_free_all);
-
- fp(a);
- }
-
- inline long BIO_ctrl(BIO *bp, int cmd, long larg, void *parg)
- {
- typedef long(FuncType)(BIO*, int, long, void*);
-
- FuncType* fp = reinterpret_cast<FuncType*>(SslGateway::GetInstance().GetFunctions().fpBIO_ctrl);
-
- return fp(bp, cmd, larg, parg);
- }
-
- inline long BIO_get_fd_(BIO *bp, int *fd)
- {
- return ssl::BIO_ctrl(bp, BIO_C_GET_FD, 0, reinterpret_cast<void*>(fd));
- }
-
- inline long BIO_get_ssl_(BIO *bp, SSL** ssl)
- {
- return ssl::BIO_ctrl(bp, BIO_C_GET_SSL, 0, reinterpret_cast<void*>(ssl));
- }
-
- inline long BIO_set_nbio_(BIO *bp, long n)
- {
- return ssl::BIO_ctrl(bp, BIO_C_SET_NBIO, n, NULL);
- }
-
- inline long BIO_set_conn_hostname_(BIO *bp, const char *name)
- {
- return ssl::BIO_ctrl(bp, BIO_C_SET_CONNECT, 0, const_cast<char*>(name));
- }
-
- inline unsigned long ERR_get_error_()
- {
- typedef unsigned long(FuncType)();
-
- FuncType* fp = reinterpret_cast<FuncType*>(SslGateway::GetInstance().GetFunctions().fpERR_get_error);
-
- return fp();
- }
-
- inline void ERR_error_string_n_(unsigned long e, char *buf, size_t len)
- {
- typedef void(FuncType)(unsigned long, char*, size_t);
-
- FuncType* fp = reinterpret_cast<FuncType*>(
- SslGateway::GetInstance().GetFunctions().fpERR_error_string_n);
-
- fp(e, buf, len);
- }
- }
- }
-}
-
-#endif //_IGNITE_ODBC_SSL_SSL_BINDINGS
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/4c48ae0a/modules/platforms/cpp/odbc/include/ignite/odbc/ssl/ssl_gateway.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/ssl/ssl_gateway.h b/modules/platforms/cpp/odbc/include/ignite/odbc/ssl/ssl_gateway.h
index 4b102ad..02761b2 100644
--- a/modules/platforms/cpp/odbc/include/ignite/odbc/ssl/ssl_gateway.h
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/ssl/ssl_gateway.h
@@ -18,6 +18,10 @@
#ifndef _IGNITE_ODBC_SSL_SSL_LIBRARY
#define _IGNITE_ODBC_SSL_SSL_LIBRARY
+#include <openssl/ssl.h>
+#include <openssl/conf.h>
+#include <openssl/err.h>
+
#include "ignite/common/concurrent.h"
#include "ignite/common/dynamic_load_os.h"
@@ -32,6 +36,7 @@ namespace ignite
*/
struct SslFunctions
{
+ void *fpSSLeay_version;
void *fpSSL_CTX_new;
void *fpSSL_CTX_free;
void *fpSSL_CTX_set_verify;
@@ -63,6 +68,12 @@ namespace ignite
void *fpBIO_ctrl;
void *fpERR_get_error;
void *fpERR_error_string_n;
+ void *fpERR_print_errors_fp;
+
+ void *fpOpenSSL_version;
+ void *fpSSL_CTX_set_options;
+ void *fpOPENSSL_init_ssl;
+ void *fpTLS_client_method;
};
/**
@@ -103,6 +114,88 @@ namespace ignite
return inited;
}
+ char* SSLeay_version_(int type);
+
+ int OPENSSL_init_ssl_(uint64_t opts, const void* settings);
+
+ long SSL_CTX_set_options_(SSL_CTX* ctx, long options);
+
+ long SSL_CTX_ctrl_(SSL_CTX* ctx, int cmd, long larg, void* parg);
+
+ SSL_CTX* SSL_CTX_new_(const SSL_METHOD* meth);
+
+ void SSL_CTX_free_(SSL_CTX* ctx);
+
+ void SSL_CTX_set_verify_(SSL_CTX* ctx, int mode, int (*callback)(int, X509_STORE_CTX*));
+
+ void SSL_CTX_set_verify_depth_(SSL_CTX* ctx, int depth);
+
+ int SSL_CTX_load_verify_locations_(SSL_CTX* ctx, const char* cAfile, const char* cApath);
+
+ int SSL_CTX_use_certificate_chain_file_(SSL_CTX* ctx, const char* file);
+
+ int SSL_CTX_use_RSAPrivateKey_file_(SSL_CTX* ctx, const char* file, int type);
+
+ int SSL_CTX_set_cipher_list_(SSL_CTX* ctx, const char* str);
+
+ long SSL_get_verify_result_(const SSL* s);
+
+ int SSL_library_init_();
+
+ void SSL_load_error_strings_();
+
+ X509* SSL_get_peer_certificate_(const SSL* s);
+
+ long SSL_ctrl_(SSL* s, int cmd, long larg, void* parg);
+
+ long SSL_set_tlsext_host_name_(SSL* s, const char* name);
+
+ void SSL_set_connect_state_(SSL* s);
+
+ int SSL_connect_(SSL* s);
+
+ int SSL_get_error_(const SSL* s, int ret);
+
+ int SSL_want_(const SSL* s);
+
+ int SSL_write_(SSL* s, const void* buf, int num);
+
+ int SSL_read_(SSL* s, void* buf, int num);
+
+ int SSL_pending_(const SSL* ssl);
+
+ int SSL_get_fd_(const SSL* ssl);
+
+ void SSL_free_(SSL* ssl);
+
+ const SSL_METHOD* SSLv23_client_method_();
+
+ const SSL_METHOD* TLS_client_method_();
+
+ void OPENSSL_config_(const char* configName);
+
+ void X509_free_(X509* a);
+
+ BIO* BIO_new_ssl_connect_(SSL_CTX* ctx);
+
+ void BIO_free_all_(BIO* a);
+
+ long BIO_ctrl_(BIO* bp, int cmd, long larg, void* parg);
+
+ long BIO_get_fd_(BIO* bp, int* fd);
+
+ long BIO_get_ssl_(BIO* bp, SSL** ssl);
+
+ long BIO_set_nbio_(BIO* bp, long n);
+
+ long BIO_set_conn_hostname_(BIO* bp, const char* name);
+
+ unsigned long ERR_get_error_();
+
+ void ERR_error_string_n_(unsigned long e, char* buf, size_t len);
+
+ void ERR_print_errors_fp_(FILE *fd);
+
private:
/**
* Constructor.
@@ -115,6 +208,11 @@ namespace ignite
~SslGateway();
/**
+ * Unload all SSL symbols.
+ */
+ void UnloadAll();
+
+ /**
* Load SSL library.
* @param name Name.
* @return Module.
@@ -127,8 +225,22 @@ namespace ignite
bool LoadSslLibraries();
/**
+ * Load mandatory SSL methods.
+ *
+ * @throw IgniteError if can not load one of the functions.
+ */
+ void LoadMandatoryMethods();
+
+ /**
+ * Try load SSL method.
+ *
+ * @param name Name.
+ * @return Method pointer.
+ */
+ void* TryLoadSslMethod(const char* name);
+
+ /**
* Load SSL method.
- * @param mod Module.
* @param name Name.
* @return Method pointer.
*/
@@ -146,6 +258,9 @@ namespace ignite
/** ssleay32 module. */
common::dynamic::Module ssleay32;
+ /** libcrypto module. */
+ common::dynamic::Module libcrypto;
+
/** libssl module. */
common::dynamic::Module libssl;
http://git-wip-us.apache.org/repos/asf/ignite/blob/4c48ae0a/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj b/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj
index 69318ef..b583c11 100644
--- a/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj
+++ b/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj
@@ -201,6 +201,7 @@
<ClCompile Include="..\..\src\sql\sql_set_streaming_command.cpp" />
<ClCompile Include="..\..\src\sql\sql_utils.cpp" />
<ClCompile Include="..\..\src\ssl\secure_socket_client.cpp" />
+ <ClCompile Include="..\..\src\ssl\ssl_api.cpp" />
<ClCompile Include="..\..\src\ssl\ssl_gateway.cpp" />
<ClCompile Include="..\..\src\ssl\ssl_mode.cpp" />
<ClCompile Include="..\..\src\statement.cpp" />
@@ -263,7 +264,7 @@
<ClInclude Include="..\..\include\ignite\odbc\sql\sql_token.h" />
<ClInclude Include="..\..\include\ignite\odbc\sql\sql_utils.h" />
<ClInclude Include="..\..\include\ignite\odbc\ssl\secure_socket_client.h" />
- <ClInclude Include="..\..\include\ignite\odbc\ssl\ssl_bindings.h" />
+ <ClInclude Include="..\..\include\ignite\odbc\ssl\ssl_api.h" />
<ClInclude Include="..\..\include\ignite\odbc\ssl\ssl_gateway.h" />
<ClInclude Include="..\..\include\ignite\odbc\ssl\ssl_mode.h" />
<ClInclude Include="..\..\include\ignite\odbc\statement.h" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/4c48ae0a/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj.filters
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj.filters b/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj.filters
index f0e49b5..5fe3bd3 100644
--- a/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj.filters
+++ b/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj.filters
@@ -196,6 +196,9 @@
<ClCompile Include="..\..\src\streaming\streaming_context.cpp">
<Filter>Code\streaming</Filter>
</ClCompile>
+ <ClCompile Include="..\..\src\ssl\ssl_api.cpp">
+ <Filter>Code\ssl</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="module.def">
@@ -344,9 +347,6 @@
<ClInclude Include="..\..\include\ignite\odbc\ssl\ssl_gateway.h">
<Filter>Code\ssl</Filter>
</ClInclude>
- <ClInclude Include="..\..\include\ignite\odbc\ssl\ssl_bindings.h">
- <Filter>Code\ssl</Filter>
- </ClInclude>
<ClInclude Include="..\..\include\ignite\odbc\config\connection_string_parser.h">
<Filter>Code\config</Filter>
</ClInclude>
@@ -392,5 +392,8 @@
<ClInclude Include="..\..\include\ignite\odbc\streaming\streaming_context.h">
<Filter>Code\streaming</Filter>
</ClInclude>
+ <ClInclude Include="..\..\include\ignite\odbc\ssl\ssl_api.h">
+ <Filter>Code\ssl</Filter>
+ </ClInclude>
</ItemGroup>
</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/4c48ae0a/modules/platforms/cpp/odbc/src/connection.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/connection.cpp b/modules/platforms/cpp/odbc/src/connection.cpp
index b580f12..1953a16 100644
--- a/modules/platforms/cpp/odbc/src/connection.cpp
+++ b/modules/platforms/cpp/odbc/src/connection.cpp
@@ -30,7 +30,7 @@
#include "ignite/odbc/connection.h"
#include "ignite/odbc/message.h"
#include "ignite/odbc/ssl/ssl_mode.h"
-#include "ignite/odbc/ssl/ssl_gateway.h"
+#include "ignite/odbc/ssl/ssl_api.h"
#include "ignite/odbc/ssl/secure_socket_client.h"
#include "ignite/odbc/system/tcp_socket_client.h"
#include "ignite/odbc/dsn_config.h"
@@ -155,7 +155,7 @@ namespace ignite
if (sslMode != SslMode::DISABLE)
{
- bool loaded = ssl::SslGateway::GetInstance().LoadAll();
+ bool loaded = ssl::EnsureSslLoaded();
if (!loaded)
{
http://git-wip-us.apache.org/repos/asf/ignite/blob/4c48ae0a/modules/platforms/cpp/odbc/src/ssl/secure_socket_client.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/ssl/secure_socket_client.cpp b/modules/platforms/cpp/odbc/src/ssl/secure_socket_client.cpp
index 84eb1e8..f7811fb 100644
--- a/modules/platforms/cpp/odbc/src/ssl/secure_socket_client.cpp
+++ b/modules/platforms/cpp/odbc/src/ssl/secure_socket_client.cpp
@@ -22,13 +22,15 @@
#include "ignite/common/concurrent.h"
#include "ignite/odbc/system/tcp_socket_client.h"
#include "ignite/odbc/ssl/secure_socket_client.h"
-#include "ignite/odbc/ssl/ssl_bindings.h"
+#include "ignite/odbc/ssl/ssl_gateway.h"
#include "ignite/common/utils.h"
#ifndef SOCKET_ERROR
# define SOCKET_ERROR (-1)
#endif // SOCKET_ERROR
+enum { OPERATION_SUCCESS = 1 };
+
namespace ignite
{
namespace odbc
@@ -52,13 +54,15 @@ namespace ignite
CloseInteral();
if (context)
- ssl::SSL_CTX_free(reinterpret_cast<SSL_CTX*>(context));
+ SslGateway::GetInstance().SSL_CTX_free_(reinterpret_cast<SSL_CTX*>(context));
}
bool SecureSocketClient::Connect(const char* hostname, uint16_t port, int32_t,
diagnostic::Diagnosable& diag)
{
- assert(SslGateway::GetInstance().Loaded());
+ SslGateway &sslGateway = SslGateway::GetInstance();
+
+ assert(sslGateway.Loaded());
if (!context)
{
@@ -77,52 +81,52 @@ namespace ignite
if (!ssl0)
return false;
- int res = ssl::SSL_set_tlsext_host_name_(ssl0, hostname);
+ int res = sslGateway.SSL_set_tlsext_host_name_(ssl0, hostname);
if (res != OPERATION_SUCCESS)
{
+ sslGateway.SSL_free_(ssl0);
+
diag.AddStatusRecord(SqlState::SHY000_GENERAL_ERROR,
"Can not set host name for secure connection: " + GetSslError(ssl0, res));
- ssl::SSL_free_(ssl0);
-
return false;
}
- ssl::SSL_set_connect_state_(ssl0);
+ sslGateway.SSL_set_connect_state_(ssl0);
bool connected = CompleteConnectInternal(ssl0, DEFALT_CONNECT_TIMEOUT, diag);
if (!connected)
{
- ssl::SSL_free_(ssl0);
+ sslGateway.SSL_free_(ssl0);
return false;
}
// Verify a server certificate was presented during the negotiation
- X509* cert = ssl::SSL_get_peer_certificate(ssl0);
+ X509* cert = sslGateway.SSL_get_peer_certificate_(ssl0);
if (cert)
- ssl::X509_free(cert);
+ sslGateway.X509_free_(cert);
else
{
+ sslGateway.SSL_free_(ssl0);
+
diag.AddStatusRecord(SqlState::SHY000_GENERAL_ERROR,
"Remote host did not provide certificate: " + GetSslError(ssl0, res));
- ssl::SSL_free_(ssl0);
-
return false;
}
// Verify the result of chain verification
// Verification performed according to RFC 4158
- res = ssl::SSL_get_verify_result(ssl0);
+ res = sslGateway.SSL_get_verify_result_(ssl0);
if (X509_V_OK != res)
{
+ sslGateway.SSL_free_(ssl0);
+
diag.AddStatusRecord(SqlState::SHY000_GENERAL_ERROR,
"Certificate chain verification failed: " + GetSslError(ssl0, res));
- ssl::SSL_free_(ssl0);
-
return false;
}
@@ -138,7 +142,9 @@ namespace ignite
int SecureSocketClient::Send(const int8_t* data, size_t size, int32_t timeout)
{
- assert(SslGateway::GetInstance().Loaded());
+ SslGateway &sslGateway = SslGateway::GetInstance();
+
+ assert(sslGateway.Loaded());
if (!ssl)
{
@@ -149,14 +155,16 @@ namespace ignite
SSL* ssl0 = reinterpret_cast<SSL*>(ssl);
- int res = ssl::SSL_write_(ssl0, data, static_cast<int>(size));
+ int res = sslGateway.SSL_write_(ssl0, data, static_cast<int>(size));
return res;
}
int SecureSocketClient::Receive(int8_t* buffer, size_t size, int32_t timeout)
{
- assert(SslGateway::GetInstance().Loaded());
+ SslGateway &sslGateway = SslGateway::GetInstance();
+
+ assert(sslGateway.Loaded());
if (!ssl)
{
@@ -169,7 +177,7 @@ namespace ignite
int res = 0;
- if (!blocking && ssl::SSL_pending_(ssl0) == 0)
+ if (!blocking && sslGateway.SSL_pending_(ssl0) == 0)
{
res = WaitOnSocket(ssl, timeout, true);
@@ -177,7 +185,7 @@ namespace ignite
return res;
}
- res = ssl::SSL_read_(ssl0, buffer, static_cast<int>(size));
+ res = sslGateway.SSL_read_(ssl0, buffer, static_cast<int>(size));
return res;
}
@@ -190,30 +198,11 @@ namespace ignite
void* SecureSocketClient::MakeContext(const std::string& certPath, const std::string& keyPath,
const std::string& caPath, diagnostic::Diagnosable& diag)
{
- assert(SslGateway::GetInstance().Loaded());
+ SslGateway &sslGateway = SslGateway::GetInstance();
- static bool sslLibInited = false;
- static common::concurrent::CriticalSection sslCs;
+ assert(sslGateway.Loaded());
- if (!sslLibInited)
- {
- common::concurrent::CsLockGuard lock(sslCs);
-
- if (!sslLibInited)
- {
- LOG_MSG("Initializing SSL library");
-
- (void)SSL_library_init();
-
- SSL_load_error_strings();
-
- OPENSSL_config(0);
-
- sslLibInited = true;
- }
- }
-
- const SSL_METHOD* method = ssl::SSLv23_client_method_();
+ const SSL_METHOD* method = sslGateway.SSLv23_client_method_();
if (!method)
{
diag.AddStatusRecord(SqlState::SHY000_GENERAL_ERROR, "Can not get SSL method.");
@@ -221,7 +210,7 @@ namespace ignite
return 0;
}
- SSL_CTX* ctx = ssl::SSL_CTX_new(method);
+ SSL_CTX* ctx = sslGateway.SSL_CTX_new_(method);
if (!ctx)
{
diag.AddStatusRecord(SqlState::SHY000_GENERAL_ERROR, "Can not create new SSL context.");
@@ -229,57 +218,56 @@ namespace ignite
return 0;
}
- ssl::SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, 0);
+ sslGateway.SSL_CTX_set_verify_(ctx, SSL_VERIFY_PEER, 0);
- ssl::SSL_CTX_set_verify_depth(ctx, 8);
+ sslGateway.SSL_CTX_set_verify_depth_(ctx, 8);
- const long flags = SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | SSL_OP_NO_COMPRESSION;
- ssl::SSL_CTX_ctrl(ctx, SSL_CTRL_OPTIONS, flags, NULL);
+ sslGateway.SSL_CTX_set_options_(ctx, SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | SSL_OP_NO_COMPRESSION);
const char* cCaPath = caPath.empty() ? 0 : caPath.c_str();
- long res = ssl::SSL_CTX_load_verify_locations(ctx, cCaPath, 0);
+ long res = sslGateway.SSL_CTX_load_verify_locations_(ctx, cCaPath, 0);
if (res != OPERATION_SUCCESS)
{
+ sslGateway.SSL_CTX_free_(ctx);
+
diag.AddStatusRecord(SqlState::SHY000_GENERAL_ERROR,
"Can not set Certificate Authority path for secure connection.");
- ssl::SSL_CTX_free(ctx);
-
return 0;
}
- res = ssl::SSL_CTX_use_certificate_chain_file(ctx, certPath.c_str());
+ res = sslGateway.SSL_CTX_use_certificate_chain_file_(ctx, certPath.c_str());
if (res != OPERATION_SUCCESS)
{
+ sslGateway.SSL_CTX_free_(ctx);
+
diag.AddStatusRecord(SqlState::SHY000_GENERAL_ERROR,
"Can not set client certificate file for secure connection.");
- ssl::SSL_CTX_free(ctx);
-
return 0;
}
- res = ssl::SSL_CTX_use_RSAPrivateKey_file(ctx, keyPath.c_str(), SSL_FILETYPE_PEM);
+ res = sslGateway.SSL_CTX_use_RSAPrivateKey_file_(ctx, keyPath.c_str(), SSL_FILETYPE_PEM);
if (res != OPERATION_SUCCESS)
{
+ sslGateway.SSL_CTX_free_(ctx);
+
diag.AddStatusRecord(SqlState::SHY000_GENERAL_ERROR,
"Can not set private key file for secure connection.");
- ssl::SSL_CTX_free(ctx);
-
return 0;
}
const char* const PREFERRED_CIPHERS = "HIGH:!aNULL:!kRSA:!PSK:!SRP:!MD5:!RC4";
- res = ssl::SSL_CTX_set_cipher_list(ctx, PREFERRED_CIPHERS);
+ res = sslGateway.SSL_CTX_set_cipher_list_(ctx, PREFERRED_CIPHERS);
if (res != OPERATION_SUCCESS)
{
+ sslGateway.SSL_CTX_free_(ctx);
+
diag.AddStatusRecord(SqlState::SHY000_GENERAL_ERROR,
"Can not set ciphers list for secure connection.");
- ssl::SSL_CTX_free(ctx);
-
return 0;
}
@@ -289,7 +277,11 @@ namespace ignite
void* SecureSocketClient::MakeSsl(void* context, const char* hostname, uint16_t port,
bool& blocking, diagnostic::Diagnosable& diag)
{
- BIO* bio = ssl::BIO_new_ssl_connect(reinterpret_cast<SSL_CTX*>(context));
+ SslGateway &sslGateway = SslGateway::GetInstance();
+
+ assert(sslGateway.Loaded());
+
+ BIO* bio = sslGateway.BIO_new_ssl_connect_(reinterpret_cast<SSL_CTX*>(context));
if (!bio)
{
diag.AddStatusRecord(SqlState::SHY000_GENERAL_ERROR, "Can not create SSL connection.");
@@ -298,7 +290,7 @@ namespace ignite
}
blocking = false;
- long res = ssl::BIO_set_nbio_(bio, 1);
+ long res = sslGateway.BIO_set_nbio_(bio, 1);
if (res != OPERATION_SUCCESS)
{
blocking = true;
@@ -312,23 +304,23 @@ namespace ignite
std::string address = stream.str();
- res = ssl::BIO_set_conn_hostname_(bio, address.c_str());
+ res = sslGateway.BIO_set_conn_hostname_(bio, address.c_str());
if (res != OPERATION_SUCCESS)
{
- diag.AddStatusRecord(SqlState::SHY000_GENERAL_ERROR, "Can not set SSL connection hostname.");
+ sslGateway.BIO_free_all_(bio);
- ssl::BIO_free_all(bio);
+ diag.AddStatusRecord(SqlState::SHY000_GENERAL_ERROR, "Can not set SSL connection hostname.");
return 0;
}
SSL* ssl = 0;
- ssl::BIO_get_ssl_(bio, &ssl);
+ sslGateway.BIO_get_ssl_(bio, &ssl);
if (!ssl)
{
- diag.AddStatusRecord(SqlState::SHY000_GENERAL_ERROR, "Can not get SSL instance from BIO.");
+ sslGateway.BIO_free_all_(bio);
- ssl::BIO_free_all(bio);
+ diag.AddStatusRecord(SqlState::SHY000_GENERAL_ERROR, "Can not get SSL instance from BIO.");
return 0;
}
@@ -338,16 +330,20 @@ namespace ignite
bool SecureSocketClient::CompleteConnectInternal(void* ssl, int timeout, diagnostic::Diagnosable& diag)
{
+ SslGateway &sslGateway = SslGateway::GetInstance();
+
+ assert(sslGateway.Loaded());
+
SSL* ssl0 = reinterpret_cast<SSL*>(ssl);
while (true)
{
- int res = ssl::SSL_connect_(ssl0);
+ int res = sslGateway.SSL_connect_(ssl0);
if (res == OPERATION_SUCCESS)
return true;
- int sslError = ssl::SSL_get_error_(ssl0, res);
+ int sslError = sslGateway.SSL_get_error_(ssl0, res);
LOG_MSG("wait res=" << res << ", sslError=" << sslError);
@@ -359,7 +355,7 @@ namespace ignite
return false;
}
- int want = ssl::SSL_want_(ssl0);
+ int want = sslGateway.SSL_want_(ssl0);
res = WaitOnSocket(ssl, timeout, want == SSL_READING);
@@ -386,9 +382,13 @@ namespace ignite
std::string SecureSocketClient::GetSslError(void* ssl, int ret)
{
+ SslGateway &sslGateway = SslGateway::GetInstance();
+
+ assert(sslGateway.Loaded());
+
SSL* ssl0 = reinterpret_cast<SSL*>(ssl);
- int sslError = ssl::SSL_get_error_(ssl0, ret);
+ int sslError = sslGateway.SSL_get_error_(ssl0, ret);
LOG_MSG("ssl_error: " << sslError);
@@ -407,11 +407,11 @@ namespace ignite
return std::string("SSL error: ") + common::LexicalCast<std::string>(sslError);
}
- long error = ssl::ERR_get_error_();
+ long error = sslGateway.ERR_get_error_();
char errBuf[1024] = { 0 };
- ssl::ERR_error_string_n_(error, errBuf, sizeof(errBuf));
+ sslGateway.ERR_error_string_n_(error, errBuf, sizeof(errBuf));
return std::string(errBuf);
}
@@ -435,11 +435,13 @@ namespace ignite
void SecureSocketClient::CloseInteral()
{
- assert(SslGateway::GetInstance().Loaded());
+ SslGateway &sslGateway = SslGateway::GetInstance();
+
+ assert(sslGateway.Loaded());
if (ssl)
{
- ssl::SSL_free_(reinterpret_cast<SSL*>(ssl));
+ sslGateway.SSL_free_(reinterpret_cast<SSL*>(ssl));
ssl = 0;
}
@@ -447,13 +449,17 @@ namespace ignite
int SecureSocketClient::WaitOnSocket(void* ssl, int32_t timeout, bool rd)
{
+ SslGateway &sslGateway = SslGateway::GetInstance();
+
+ assert(sslGateway.Loaded());
+
int ready = 0;
int lastError = 0;
SSL* ssl0 = reinterpret_cast<SSL*>(ssl);
fd_set fds;
- int fd = ssl::SSL_get_fd_(ssl0);
+ int fd = sslGateway.SSL_get_fd_(ssl0);
if (fd < 0)
{
http://git-wip-us.apache.org/repos/asf/ignite/blob/4c48ae0a/modules/platforms/cpp/odbc/src/ssl/ssl_api.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/ssl/ssl_api.cpp b/modules/platforms/cpp/odbc/src/ssl/ssl_api.cpp
new file mode 100644
index 0000000..4a1d692
--- /dev/null
+++ b/modules/platforms/cpp/odbc/src/ssl/ssl_api.cpp
@@ -0,0 +1,33 @@
+/*
+ * 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 "ignite/odbc/ssl/ssl_gateway.h"
+#include "ignite/odbc/ssl/ssl_api.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace ssl
+ {
+ bool EnsureSslLoaded()
+ {
+ return SslGateway::GetInstance().LoadAll();
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4c48ae0a/modules/platforms/cpp/odbc/src/ssl/ssl_gateway.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/ssl/ssl_gateway.cpp b/modules/platforms/cpp/odbc/src/ssl/ssl_gateway.cpp
index 308302a..6116a76 100644
--- a/modules/platforms/cpp/odbc/src/ssl/ssl_gateway.cpp
+++ b/modules/platforms/cpp/odbc/src/ssl/ssl_gateway.cpp
@@ -17,9 +17,6 @@
#include <sstream>
-#include <openssl/ssl.h>
-#include <openssl/conf.h>
-
#include "ignite/common/utils.h"
#include "ignite/odbc/ssl/ssl_gateway.h"
@@ -29,6 +26,18 @@
# define ADDITIONAL_OPENSSL_HOME_ENV "OPEN_SSL_HOME"
#endif // ADDITIONAL_OPENSSL_HOME_ENV
+#ifndef SSL_CTRL_OPTIONS
+# define SSL_CTRL_OPTIONS 32
+#endif // SSL_CTRL_OPTIONS
+
+#ifndef OPENSSL_INIT_LOAD_SSL_STRINGS
+# define OPENSSL_INIT_LOAD_SSL_STRINGS 0x00200000L
+#endif // OPENSSL_INIT_LOAD_SSL_STRINGS
+
+#ifndef OPENSSL_INIT_LOAD_CRYPTO_STRINGS
+# define OPENSSL_INIT_LOAD_CRYPTO_STRINGS 0x00000002L
+#endif // OPENSSL_INIT_LOAD_CRYPTO_STRINGS
+
namespace ignite
{
namespace odbc
@@ -39,7 +48,7 @@ namespace ignite
inited(false),
functions()
{
- // No-op.
+ memset(&functions, 0, sizeof(functions));
}
SslGateway::~SslGateway()
@@ -47,41 +56,61 @@ namespace ignite
// No-op.
}
+ void SslGateway::UnloadAll()
+ {
+ libeay32.Unload();
+ ssleay32.Unload();
+ libssl.Unload();
+ libcrypto.Unload();
+
+ memset(&functions, 0, sizeof(functions));
+ }
+
common::dynamic::Module SslGateway::LoadSslLibrary(const char* name)
{
using namespace common;
using namespace dynamic;
- std::string fullName = GetDynamicLibraryName(name);
-
- Module libModule = LoadModule(fullName);
-
- if (libModule.IsLoaded())
- return libModule;
-
std::string home = GetEnv(ADDITIONAL_OPENSSL_HOME_ENV);
if (home.empty())
home = GetEnv("OPENSSL_HOME");
- if (home.empty())
- return libModule;
+ std::string fullName = GetDynamicLibraryName(name);
+
+ if (!home.empty())
+ {
+ std::stringstream constructor;
+
+ constructor << home << Fs << "bin" << Fs << fullName;
- std::stringstream constructor;
+ std::string fullPath = constructor.str();
- constructor << home << Fs << "bin" << Fs << fullName;
+ Module mod = LoadModule(fullPath);
- std::string fullPath = constructor.str();
+ if (mod.IsLoaded())
+ return mod;
+ }
- return LoadModule(fullPath);
+ return LoadModule(fullName);
}
bool SslGateway::LoadSslLibraries()
{
- libeay32 = LoadSslLibrary("libeay32");
- ssleay32 = LoadSslLibrary("ssleay32");
libssl = LoadSslLibrary("libssl");
+ if (!libssl.IsLoaded())
+ {
+ libcrypto = LoadSslLibrary("libcrypto-1_1-x64");
+ libssl = LoadSslLibrary("libssl-1_1-x64");
+ }
+
+ if (!libssl.IsLoaded())
+ {
+ libeay32 = LoadSslLibrary("libeay32");
+ ssleay32 = LoadSslLibrary("ssleay32");
+ }
+
if (!libssl.IsLoaded() && (!libeay32.IsLoaded() || !ssleay32.IsLoaded()))
{
if (!libeay32.IsLoaded())
@@ -93,41 +122,29 @@ namespace ignite
if (!libssl.IsLoaded())
LOG_MSG("Can not load libssl.");
- libeay32.Unload();
- ssleay32.Unload();
- libssl.Unload();
-
return false;
}
return true;
}
- SslGateway& SslGateway::GetInstance()
- {
- static SslGateway self;
-
- return self;
- }
-
- bool SslGateway::LoadAll()
+ void SslGateway::LoadMandatoryMethods()
{
- using namespace common::dynamic;
+ functions.fpSSLeay_version = TryLoadSslMethod("SSLeay_version");
- if (inited)
- return true;
+ if (!functions.fpSSLeay_version)
+ functions.fpOpenSSL_version = LoadSslMethod("OpenSSL_version");
- common::concurrent::CsLockGuard lock(initCs);
+ functions.fpSSL_library_init = TryLoadSslMethod("SSL_library_init");
+ functions.fpSSL_load_error_strings = TryLoadSslMethod("SSL_load_error_strings");
- if (inited)
- return true;
+ if (!functions.fpSSL_library_init || !functions.fpSSL_load_error_strings)
+ functions.fpOPENSSL_init_ssl = LoadSslMethod("OPENSSL_init_ssl");
- if (!LoadSslLibraries())
- {
- LOG_MSG("Can not load neccessary OpenSSL libraries.");
+ functions.fpSSLv23_client_method = TryLoadSslMethod("SSLv23_client_method");
- return false;
- }
+ if (!functions.fpSSLv23_client_method)
+ functions.fpTLS_client_method = LoadSslMethod("TLS_client_method");
functions.fpSSL_CTX_new = LoadSslMethod("SSL_CTX_new");
functions.fpSSL_CTX_free = LoadSslMethod("SSL_CTX_free");
@@ -139,13 +156,11 @@ namespace ignite
functions.fpSSL_CTX_set_cipher_list = LoadSslMethod("SSL_CTX_set_cipher_list");
functions.fpSSL_get_verify_result = LoadSslMethod("SSL_get_verify_result");
- functions.fpSSL_library_init = LoadSslMethod("SSL_library_init");
- functions.fpSSL_load_error_strings = LoadSslMethod("SSL_load_error_strings");
+
functions.fpSSL_get_peer_certificate = LoadSslMethod("SSL_get_peer_certificate");
functions.fpSSL_ctrl = LoadSslMethod("SSL_ctrl");
functions.fpSSL_CTX_ctrl = LoadSslMethod("SSL_CTX_ctrl");
- functions.fpSSLv23_client_method = LoadSslMethod("SSLv23_client_method");
functions.fpSSL_set_connect_state = LoadSslMethod("SSL_set_connect_state");
functions.fpSSL_connect = LoadSslMethod("SSL_connect");
functions.fpSSL_get_error = LoadSslMethod("SSL_get_error");
@@ -165,53 +180,55 @@ namespace ignite
functions.fpERR_get_error = LoadSslMethod("ERR_get_error");
functions.fpERR_error_string_n = LoadSslMethod("ERR_error_string_n");
+ }
+
+ SslGateway& SslGateway::GetInstance()
+ {
+ static SslGateway self;
+
+ return self;
+ }
+
+ bool SslGateway::LoadAll()
+ {
+ using namespace common::dynamic;
+
+ if (inited)
+ return true;
+
+ common::concurrent::CsLockGuard lock(initCs);
- bool allLoaded =
- functions.fpSSL_CTX_new != 0 &&
- functions.fpSSL_CTX_free != 0 &&
- functions.fpSSL_CTX_set_verify != 0 &&
- functions.fpSSL_CTX_set_verify_depth != 0 &&
- functions.fpSSL_CTX_load_verify_locations != 0 &&
- functions.fpSSL_CTX_use_certificate_chain_file != 0 &&
- functions.fpSSL_CTX_use_RSAPrivateKey_file != 0 &&
- functions.fpSSL_CTX_set_cipher_list != 0 &&
- functions.fpSSL_get_verify_result != 0 &&
- functions.fpSSL_library_init != 0 &&
- functions.fpSSL_load_error_strings != 0 &&
- functions.fpSSL_get_peer_certificate != 0 &&
- functions.fpSSL_ctrl != 0 &&
- functions.fpSSL_CTX_ctrl != 0 &&
- functions.fpSSLv23_client_method != 0 &&
- functions.fpSSL_set_connect_state != 0 &&
- functions.fpSSL_connect != 0 &&
- functions.fpSSL_get_error != 0 &&
- functions.fpSSL_want != 0 &&
- functions.fpSSL_write != 0 &&
- functions.fpSSL_read != 0 &&
- functions.fpSSL_pending != 0 &&
- functions.fpSSL_get_fd != 0 &&
- functions.fpSSL_free != 0 &&
- functions.fpBIO_new_ssl_connect != 0 &&
- functions.fpOPENSSL_config != 0 &&
- functions.fpX509_free != 0 &&
- functions.fpBIO_free_all != 0 &&
- functions.fpBIO_ctrl != 0 &&
- functions.fpERR_get_error != 0 &&
- functions.fpERR_error_string_n != 0;
-
- if (!allLoaded)
+ if (inited)
+ return true;
+
+ common::MethodGuard<SslGateway> guard(this, &SslGateway::UnloadAll);
+
+ if (!LoadSslLibraries())
{
- libeay32.Unload();
- ssleay32.Unload();
- libssl.Unload();
+ LOG_MSG("Can not load neccessary OpenSSL libraries.");
+
+ return false;
}
- inited = allLoaded;
+ LoadMandatoryMethods();
+
+ functions.fpSSL_CTX_set_options = TryLoadSslMethod("SSL_CTX_set_options");
+ functions.fpERR_print_errors_fp = TryLoadSslMethod("ERR_print_errors_fp");
+
+ (void)SSL_library_init_();
- return inited;
+ SSL_load_error_strings_();
+
+ OPENSSL_config_(0);
+
+ guard.Release();
+
+ inited = true;
+
+ return true;
}
- void* SslGateway::LoadSslMethod(const char* name)
+ void* SslGateway::TryLoadSslMethod(const char* name)
{
void* fp = libeay32.FindSymbol(name);
@@ -219,13 +236,465 @@ namespace ignite
fp = ssleay32.FindSymbol(name);
if (!fp)
+ fp = libcrypto.FindSymbol(name);
+
+ if (!fp)
fp = libssl.FindSymbol(name);
+ return fp;
+ }
+
+ void* SslGateway::LoadSslMethod(const char* name)
+ {
+ void* fp = TryLoadSslMethod(name);
+
if (!fp)
LOG_MSG("Can not load function " << name);
return fp;
}
+
+ char* SslGateway::SSLeay_version_(int type)
+ {
+ typedef char* (FuncType)(int);
+
+ FuncType* fp = 0;
+
+ if (functions.fpSSLeay_version)
+ fp = reinterpret_cast<FuncType*>(functions.fpSSLeay_version);
+ else
+ fp = reinterpret_cast<FuncType*>(functions.fpOpenSSL_version);
+
+ assert(fp != 0);
+
+ return fp(type);
+ }
+
+ int SslGateway::OPENSSL_init_ssl_(uint64_t opts, const void* settings)
+ {
+ assert(functions.fpOPENSSL_init_ssl != 0);
+
+ typedef int (FuncType)(uint64_t, const void*);
+
+ FuncType* fp = reinterpret_cast<FuncType*>(functions.fpOPENSSL_init_ssl);
+
+ return fp(opts, settings);
+ }
+
+ long SslGateway::SSL_CTX_set_options_(SSL_CTX* ctx, long options)
+ {
+ if (functions.fpSSL_CTX_set_options)
+ {
+ typedef long (FuncType)(SSL_CTX*, long);
+
+ FuncType* fp = reinterpret_cast<FuncType*>(functions.fpSSL_CTX_set_options);
+
+ return fp(ctx, options);
+ }
+
+ return SSL_CTX_ctrl_(ctx, SSL_CTRL_OPTIONS, options, NULL);
+ }
+
+ long SslGateway::SSL_CTX_ctrl_(SSL_CTX* ctx, int cmd, long larg, void* parg)
+ {
+ assert(functions.fpSSL_CTX_ctrl != 0);
+
+ typedef long (FuncType)(SSL_CTX*, int, long, void*);
+
+ FuncType* fp = reinterpret_cast<FuncType*>(functions.fpSSL_CTX_ctrl);
+
+ return fp(ctx, cmd, larg, parg);
+ }
+
+ SSL_CTX* SslGateway::SSL_CTX_new_(const SSL_METHOD* meth)
+ {
+ assert(functions.fpSSL_CTX_new != 0);
+
+ typedef SSL_CTX*(FuncType)(const SSL_METHOD*);
+
+ FuncType* fp = reinterpret_cast<FuncType*>(functions.fpSSL_CTX_new);
+
+ return fp(meth);
+ }
+
+ void SslGateway::SSL_CTX_free_(SSL_CTX* ctx)
+ {
+ assert(functions.fpSSL_CTX_free != 0);
+
+ typedef void (FuncType)(SSL_CTX*);
+
+ FuncType* fp = reinterpret_cast<FuncType*>(functions.fpSSL_CTX_free);
+
+ fp(ctx);
+ }
+
+ void SslGateway::SSL_CTX_set_verify_(SSL_CTX* ctx, int mode, int (* callback)(int, X509_STORE_CTX*))
+ {
+ assert(functions.fpSSL_CTX_set_verify != 0);
+
+ typedef void (FuncType)(SSL_CTX*, int, int (*)(int, X509_STORE_CTX*));
+
+ FuncType* fp = reinterpret_cast<FuncType*>(functions.fpSSL_CTX_set_verify);
+
+ fp(ctx, mode, callback);
+ }
+
+ void SslGateway::SSL_CTX_set_verify_depth_(SSL_CTX* ctx, int depth)
+ {
+ assert(functions.fpSSL_CTX_set_verify_depth != 0);
+
+ typedef void (FuncType)(SSL_CTX*, int);
+
+ FuncType* fp = reinterpret_cast<FuncType*>(functions.fpSSL_CTX_set_verify_depth);
+
+ fp(ctx, depth);
+ }
+
+ int SslGateway::SSL_CTX_load_verify_locations_(SSL_CTX* ctx, const char* cAfile, const char* cApath)
+ {
+ assert(functions.fpSSL_CTX_load_verify_locations != 0);
+
+ typedef int (FuncType)(SSL_CTX*, const char*, const char*);
+
+ FuncType* fp = reinterpret_cast<FuncType*>(functions.fpSSL_CTX_load_verify_locations);
+
+ return fp(ctx, cAfile, cApath);
+ }
+
+ int SslGateway::SSL_CTX_use_certificate_chain_file_(SSL_CTX* ctx, const char* file)
+ {
+ assert(functions.fpSSL_CTX_use_certificate_chain_file != 0);
+
+ typedef int (FuncType)(SSL_CTX*, const char*);
+
+ FuncType* fp = reinterpret_cast<FuncType*>(functions.fpSSL_CTX_use_certificate_chain_file);
+
+ return fp(ctx, file);
+ }
+
+ int SslGateway::SSL_CTX_use_RSAPrivateKey_file_(SSL_CTX* ctx, const char* file, int type)
+ {
+ assert(functions.fpSSL_CTX_use_RSAPrivateKey_file != 0);
+
+ typedef int (FuncType)(SSL_CTX*, const char*, int);
+
+ FuncType* fp = reinterpret_cast<FuncType*>(functions.fpSSL_CTX_use_RSAPrivateKey_file);
+
+ return fp(ctx, file, type);
+ }
+
+ int SslGateway::SSL_CTX_set_cipher_list_(SSL_CTX* ctx, const char* str)
+ {
+ assert(functions.fpSSL_CTX_set_cipher_list != 0);
+
+ typedef int (FuncType)(SSL_CTX*, const char*);
+
+ FuncType* fp = reinterpret_cast<FuncType*>(functions.fpSSL_CTX_set_cipher_list);
+
+ return fp(ctx, str);
+ }
+
+ long SslGateway::SSL_get_verify_result_(const SSL* s)
+ {
+ assert(functions.fpSSL_get_verify_result != 0);
+
+ typedef long (FuncType)(const SSL*);
+
+ FuncType* fp = reinterpret_cast<FuncType*>(functions.fpSSL_get_verify_result);
+
+ return fp(s);
+ }
+
+ int SslGateway::SSL_library_init_()
+ {
+ typedef int (FuncType)();
+
+ if (functions.fpSSL_library_init)
+ {
+ FuncType* fp = reinterpret_cast<FuncType*>(functions.fpSSL_library_init);
+
+ return fp();
+ }
+
+ return OPENSSL_init_ssl_(0, NULL);
+ }
+
+ void SslGateway::SSL_load_error_strings_()
+ {
+ typedef void (FuncType)();
+
+ if (functions.fpSSL_load_error_strings)
+ {
+ FuncType* fp = reinterpret_cast<FuncType*>(functions.fpSSL_load_error_strings);
+
+ fp();
+
+ return;
+ }
+
+ OPENSSL_init_ssl_(OPENSSL_INIT_LOAD_SSL_STRINGS | OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL);
+ }
+
+ X509* SslGateway::SSL_get_peer_certificate_(const SSL* s)
+ {
+ assert(functions.fpSSL_get_peer_certificate != 0);
+
+ typedef X509*(FuncType)(const SSL*);
+
+ FuncType* fp = reinterpret_cast<FuncType*>(functions.fpSSL_get_peer_certificate);
+
+ return fp(s);
+ }
+
+ long SslGateway::SSL_ctrl_(SSL* s, int cmd, long larg, void* parg)
+ {
+ assert(functions.fpSSL_ctrl != 0);
+
+ typedef long (FuncType)(SSL*, int, long, void*);
+
+ FuncType* fp = reinterpret_cast<FuncType*>(functions.fpSSL_ctrl);
+
+ return fp(s, cmd, larg, parg);
+ }
+
+ long SslGateway::SSL_set_tlsext_host_name_(SSL* s, const char* name)
+ {
+ return SSL_ctrl_(s, SSL_CTRL_SET_TLSEXT_HOSTNAME,
+ TLSEXT_NAMETYPE_host_name, const_cast<char*>(name));
+ }
+
+ void SslGateway::SSL_set_connect_state_(SSL* s)
+ {
+ assert(functions.fpSSL_set_connect_state != 0);
+
+ typedef void (FuncType)(SSL*);
+
+ FuncType* fp = reinterpret_cast<FuncType*>(functions.fpSSL_set_connect_state);
+
+ return fp(s);
+ }
+
+ int SslGateway::SSL_connect_(SSL* s)
+ {
+ assert(functions.fpSSL_connect != 0);
+
+ typedef int (FuncType)(SSL*);
+
+ FuncType* fp = reinterpret_cast<FuncType*>(functions.fpSSL_connect);
+
+ return fp(s);
+ }
+
+ int SslGateway::SSL_get_error_(const SSL* s, int ret)
+ {
+ assert(functions.fpSSL_get_error != 0);
+
+ typedef int (FuncType)(const SSL*, int);
+
+ FuncType* fp = reinterpret_cast<FuncType*>(functions.fpSSL_get_error);
+
+ return fp(s, ret);
+ }
+
+ int SslGateway::SSL_want_(const SSL* s)
+ {
+ assert(functions.fpSSL_want != 0);
+
+ typedef int (FuncType)(const SSL*);
+
+ FuncType* fp = reinterpret_cast<FuncType*>(functions.fpSSL_want);
+
+ return fp(s);
+ }
+
+ int SslGateway::SSL_write_(SSL* s, const void* buf, int num)
+ {
+ assert(functions.fpSSL_write != 0);
+
+ typedef int (FuncType)(SSL*, const void*, int);
+
+ FuncType* fp = reinterpret_cast<FuncType*>(functions.fpSSL_write);
+
+ return fp(s, buf, num);
+ }
+
+ int SslGateway::SSL_read_(SSL* s, void* buf, int num)
+ {
+ assert(functions.fpSSL_read != 0);
+
+ typedef int (FuncType)(SSL*, void*, int);
+
+ FuncType* fp = reinterpret_cast<FuncType*>(functions.fpSSL_read);
+
+ return fp(s, buf, num);
+ }
+
+ int SslGateway::SSL_pending_(const SSL* ssl)
+ {
+ assert(functions.fpSSL_pending != 0);
+
+ typedef int (FuncType)(const SSL*);
+
+ FuncType* fp = reinterpret_cast<FuncType*>(functions.fpSSL_pending);
+
+ return fp(ssl);
+ }
+
+ int SslGateway::SSL_get_fd_(const SSL* ssl)
+ {
+ assert(functions.fpSSL_get_fd != 0);
+
+ typedef int (FuncType)(const SSL*);
+
+ FuncType* fp = reinterpret_cast<FuncType*>(functions.fpSSL_get_fd);
+
+ return fp(ssl);
+ }
+
+ void SslGateway::SSL_free_(SSL* ssl)
+ {
+ assert(functions.fpSSL_free != 0);
+
+ typedef void (FuncType)(SSL*);
+
+ FuncType* fp = reinterpret_cast<FuncType*>(functions.fpSSL_free);
+
+ fp(ssl);
+ }
+
+ const SSL_METHOD* SslGateway::SSLv23_client_method_()
+ {
+ if (functions.fpSSLv23_client_method)
+ {
+ typedef const SSL_METHOD*(FuncType)();
+
+ FuncType* fp = reinterpret_cast<FuncType*>(functions.fpSSLv23_client_method);
+
+ return fp();
+ }
+
+ return TLS_client_method_();
+ }
+
+ const SSL_METHOD* SslGateway::TLS_client_method_()
+ {
+ assert(functions.fpTLS_client_method != 0);
+
+ typedef const SSL_METHOD*(FuncType)();
+
+ FuncType* fp = reinterpret_cast<FuncType*>(functions.fpTLS_client_method);
+
+ return fp();
+ }
+
+ void SslGateway::OPENSSL_config_(const char* configName)
+ {
+ assert(functions.fpOPENSSL_config != 0);
+
+ typedef void (FuncType)(const char*);
+
+ FuncType* fp = reinterpret_cast<FuncType*>(functions.fpOPENSSL_config);
+
+ fp(configName);
+ }
+
+ void SslGateway::X509_free_(X509* a)
+ {
+ assert(functions.fpX509_free != 0);
+
+ typedef void (FuncType)(X509*);
+
+ FuncType* fp = reinterpret_cast<FuncType*>(functions.fpX509_free);
+
+ fp(a);
+ }
+
+ BIO* SslGateway::BIO_new_ssl_connect_(SSL_CTX* ctx)
+ {
+ assert(functions.fpBIO_new_ssl_connect != 0);
+
+ typedef BIO*(FuncType)(SSL_CTX*);
+
+ FuncType* fp = reinterpret_cast<FuncType*>(functions.fpBIO_new_ssl_connect);
+
+ return fp(ctx);
+ }
+
+ void SslGateway::BIO_free_all_(BIO* a)
+ {
+ assert(functions.fpBIO_free_all != 0);
+
+ typedef void (FuncType)(BIO*);
+
+ FuncType* fp = reinterpret_cast<FuncType*>(functions.fpBIO_free_all);
+
+ fp(a);
+ }
+
+ long SslGateway::BIO_ctrl_(BIO* bp, int cmd, long larg, void* parg)
+ {
+ assert(functions.fpBIO_ctrl != 0);
+
+ typedef long (FuncType)(BIO*, int, long, void*);
+
+ FuncType* fp = reinterpret_cast<FuncType*>(functions.fpBIO_ctrl);
+
+ return fp(bp, cmd, larg, parg);
+ }
+
+ long SslGateway::BIO_get_fd_(BIO* bp, int* fd)
+ {
+ return BIO_ctrl_(bp, BIO_C_GET_FD, 0, reinterpret_cast<void*>(fd));
+ }
+
+ long SslGateway::BIO_get_ssl_(BIO* bp, SSL** ssl)
+ {
+ return BIO_ctrl_(bp, BIO_C_GET_SSL, 0, reinterpret_cast<void*>(ssl));
+ }
+
+ long SslGateway::BIO_set_nbio_(BIO* bp, long n)
+ {
+ return BIO_ctrl_(bp, BIO_C_SET_NBIO, n, NULL);
+ }
+
+ long SslGateway::BIO_set_conn_hostname_(BIO* bp, const char* name)
+ {
+ return BIO_ctrl_(bp, BIO_C_SET_CONNECT, 0, const_cast<char*>(name));
+ }
+
+ unsigned long SslGateway::ERR_get_error_()
+ {
+ assert(functions.fpERR_get_error != 0);
+
+ typedef unsigned long (FuncType)();
+
+ FuncType* fp = reinterpret_cast<FuncType*>(functions.fpERR_get_error);
+
+ return fp();
+ }
+
+ void SslGateway::ERR_error_string_n_(unsigned long e, char* buf, size_t len)
+ {
+ assert(functions.fpERR_error_string_n != 0);
+
+ typedef void (FuncType)(unsigned long, char*, size_t);
+
+ FuncType* fp = reinterpret_cast<FuncType*>(functions.fpERR_error_string_n);
+
+ fp(e, buf, len);
+ }
+
+ void SslGateway::ERR_print_errors_fp_(FILE* fd)
+ {
+ if (!functions.fpERR_print_errors_fp)
+ return;
+
+ typedef void (FuncType)(FILE*);
+
+ FuncType* fp = reinterpret_cast<FuncType*>(functions.fpERR_print_errors_fp);
+
+ fp(fd);
+ }
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4c48ae0a/modules/platforms/cpp/thin-client-test/src/ssl_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/thin-client-test/src/ssl_test.cpp b/modules/platforms/cpp/thin-client-test/src/ssl_test.cpp
index 6bfda49..eaadd9b 100644
--- a/modules/platforms/cpp/thin-client-test/src/ssl_test.cpp
+++ b/modules/platforms/cpp/thin-client-test/src/ssl_test.cpp
@@ -96,7 +96,7 @@ BOOST_AUTO_TEST_CASE(SslConnectionReject2)
cfg.SetEndPoints("127.0.0.1:11110");
cfg.SetSslMode(SslMode::DISABLE);
-
+
BOOST_CHECK_THROW(IgniteClient::Start(cfg), ignite::IgniteError);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4c48ae0a/modules/platforms/cpp/thin-client/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/thin-client/Makefile.am b/modules/platforms/cpp/thin-client/Makefile.am
index f8d9190..1efff8e 100644
--- a/modules/platforms/cpp/thin-client/Makefile.am
+++ b/modules/platforms/cpp/thin-client/Makefile.am
@@ -63,6 +63,7 @@ libignite_thin_client_la_SOURCES = \
src/impl/data_router.cpp \
src/impl/ssl/ssl_gateway.cpp \
src/impl/ssl/secure_socket_client.cpp \
+ src/impl/ssl/ssl_api.cpp \
src/ignite_client.cpp
clean-local:
http://git-wip-us.apache.org/repos/asf/ignite/blob/4c48ae0a/modules/platforms/cpp/thin-client/project/vs/thin-client.vcxproj
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/thin-client/project/vs/thin-client.vcxproj b/modules/platforms/cpp/thin-client/project/vs/thin-client.vcxproj
index 3221268..9c00913 100644
--- a/modules/platforms/cpp/thin-client/project/vs/thin-client.vcxproj
+++ b/modules/platforms/cpp/thin-client/project/vs/thin-client.vcxproj
@@ -166,6 +166,7 @@
<ClCompile Include="..\..\src\impl\net\remote_type_updater.cpp" />
<ClCompile Include="..\..\src\impl\protocol_version.cpp" />
<ClCompile Include="..\..\src\impl\ssl\secure_socket_client.cpp" />
+ <ClCompile Include="..\..\src\impl\ssl\ssl_api.cpp" />
<ClCompile Include="..\..\src\impl\ssl\ssl_gateway.cpp" />
<ClCompile Include="..\..\src\impl\utility.cpp" />
</ItemGroup>
@@ -195,7 +196,7 @@
<ClInclude Include="..\..\src\impl\response_status.h" />
<ClInclude Include="..\..\src\impl\socket_client.h" />
<ClInclude Include="..\..\src\impl\ssl\secure_socket_client.h" />
- <ClInclude Include="..\..\src\impl\ssl\ssl_bindings.h" />
+ <ClInclude Include="..\..\src\impl\ssl\ssl_api.h" />
<ClInclude Include="..\..\src\impl\ssl\ssl_gateway.h" />
<ClInclude Include="..\..\src\impl\utility.h" />
</ItemGroup>
@@ -210,4 +211,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project>
+</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/4c48ae0a/modules/platforms/cpp/thin-client/project/vs/thin-client.vcxproj.filters
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/thin-client/project/vs/thin-client.vcxproj.filters b/modules/platforms/cpp/thin-client/project/vs/thin-client.vcxproj.filters
index 2d20106..a5cad74 100644
--- a/modules/platforms/cpp/thin-client/project/vs/thin-client.vcxproj.filters
+++ b/modules/platforms/cpp/thin-client/project/vs/thin-client.vcxproj.filters
@@ -67,6 +67,9 @@
<ClCompile Include="..\..\src\impl\cache\cache_affinity_info.cpp">
<Filter>Code\impl\cache</Filter>
</ClCompile>
+ <ClCompile Include="..\..\src\impl\ssl\ssl_api.cpp">
+ <Filter>Code\impl\ssl</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\include\ignite\thin\ignite_client.h">
@@ -123,9 +126,6 @@
<ClInclude Include="..\..\src\impl\ssl\secure_socket_client.h">
<Filter>Code\impl\ssl</Filter>
</ClInclude>
- <ClInclude Include="..\..\src\impl\ssl\ssl_bindings.h">
- <Filter>Code\impl\ssl</Filter>
- </ClInclude>
<ClInclude Include="..\..\src\impl\ssl\ssl_gateway.h">
<Filter>Code\impl\ssl</Filter>
</ClInclude>
@@ -153,5 +153,8 @@
<ClInclude Include="..\..\src\impl\cache\cache_affinity_info.h">
<Filter>Code\impl\cache</Filter>
</ClInclude>
+ <ClInclude Include="..\..\src\impl\ssl\ssl_api.h">
+ <Filter>Code\impl\ssl</Filter>
+ </ClInclude>
</ItemGroup>
-</Project>
+</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/4c48ae0a/modules/platforms/cpp/thin-client/src/impl/data_channel.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/thin-client/src/impl/data_channel.cpp b/modules/platforms/cpp/thin-client/src/impl/data_channel.cpp
index 6b40d81..592dba3 100644
--- a/modules/platforms/cpp/thin-client/src/impl/data_channel.cpp
+++ b/modules/platforms/cpp/thin-client/src/impl/data_channel.cpp
@@ -23,7 +23,7 @@
#include <ignite/common/fixed_size_array.h>
#include "impl/message.h"
-#include "impl/ssl/ssl_gateway.h"
+#include "impl/ssl/ssl_api.h"
#include "impl/ssl/secure_socket_client.h"
#include "impl/net/tcp_socket_client.h"
#include "impl/net/remote_type_updater.h"
@@ -81,7 +81,7 @@ namespace ignite
if (sslMode != SslMode::DISABLE)
{
- ssl::SslGateway::GetInstance().LoadAll();
+ ssl::EnsureSslLoaded();
socket.reset(new ssl::SecureSocketClient(config.GetSslCertFile(),
config.GetSslKeyFile(), config.GetSslCaFile()));