You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by mm...@apache.org on 2019/05/08 19:12:51 UTC

[geode-native] branch develop updated: GEODE-3415: Use SslException with fixed circular dependency

This is an automated email from the ASF dual-hosted git repository.

mmartell pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode-native.git


The following commit(s) were added to refs/heads/develop by this push:
     new 942db0f  GEODE-3415: Use SslException with fixed circular dependency
942db0f is described below

commit 942db0ff19ebdbf192e8e5032d8e61549ab1d075
Author: Michael Martell <mm...@pivotal.io>
AuthorDate: Wed May 8 12:12:46 2019 -0700

    GEODE-3415: Use SslException with fixed circular dependency
    
    * Throw std::invalid_argument instead of std::exception to allow passing a message
---
 cppcache/src/TcpSslConn.cpp |  6 +++++-
 cryptoimpl/CMakeLists.txt   |  1 -
 cryptoimpl/DHImpl.cpp       |  2 --
 cryptoimpl/SSLImpl.cpp      | 13 +++++--------
 4 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/cppcache/src/TcpSslConn.cpp b/cppcache/src/TcpSslConn.cpp
index 8712ad0..de80c4d 100644
--- a/cppcache/src/TcpSslConn.cpp
+++ b/cppcache/src/TcpSslConn.cpp
@@ -55,7 +55,11 @@ Ssl* TcpSslConn::getSSLImpl(ACE_HANDLE sock, const char* pubkeyfile,
 
 void TcpSslConn::createSocket(ACE_HANDLE sock) {
   LOGDEBUG("Creating SSL socket stream");
-  m_ssl = getSSLImpl(sock, m_pubkeyfile, m_privkeyfile);
+  try {
+    m_ssl = getSSLImpl(sock, m_pubkeyfile, m_privkeyfile);
+  } catch (std::exception e) {
+    throw SslException(e.what());
+  }
 }
 
 void TcpSslConn::listen(ACE_INET_Addr addr,
diff --git a/cryptoimpl/CMakeLists.txt b/cryptoimpl/CMakeLists.txt
index 5d4a609..22a3856 100644
--- a/cryptoimpl/CMakeLists.txt
+++ b/cryptoimpl/CMakeLists.txt
@@ -42,7 +42,6 @@ target_link_libraries(cryptoImpl
     ACE::ACE_SSL
     _WarningsAsError
   PUBLIC
-    apache-geode
     OpenSSL::Crypto
     OpenSSL::SSL
     c++11
diff --git a/cryptoimpl/DHImpl.cpp b/cryptoimpl/DHImpl.cpp
index 9db49f7..1365d32 100644
--- a/cryptoimpl/DHImpl.cpp
+++ b/cryptoimpl/DHImpl.cpp
@@ -33,8 +33,6 @@
 #include <cstring>
 #include <memory>
 
-#include <geode/internal/geode_globals.hpp>
-
 /*
 static DH * m_dh = nullptr;
 static string m_skAlgo;
diff --git a/cryptoimpl/SSLImpl.cpp b/cryptoimpl/SSLImpl.cpp
index 97d5b40..b93b766 100644
--- a/cryptoimpl/SSLImpl.cpp
+++ b/cryptoimpl/SSLImpl.cpp
@@ -18,13 +18,10 @@
 #include "SSLImpl.hpp"
 
 #include <cstdint>
+#include <stdexcept>
 
 #include <ace/Guard_T.h>
 
-#include <geode/ExceptionTypes.hpp>
-
-#include "../cppcache/src/util/exception.hpp"
-
 namespace apache {
 namespace geode {
 namespace client {
@@ -61,7 +58,7 @@ SSLImpl::SSLImpl(ACE_HANDLE sock, const char *pubkeyfile,
     SSL_CTX_set_cipher_list(sslctx->context(), "DEFAULT");
     sslctx->set_mode(ACE_SSL_Context::SSLv23_client);
     if (sslctx->load_trusted_ca(pubkeyfile) != 0) {
-      throw SslException("Failed to read SSL trust store.");
+      throw std::invalid_argument("Failed to read SSL trust store.");
     }
 
     if (strlen(password) > 0) {
@@ -71,14 +68,14 @@ SSLImpl::SSLImpl(ACE_HANDLE sock, const char *pubkeyfile,
     }
 
     if (sslctx->private_key(privkeyfile) != 0) {
-      throw SslException("Invalid SSL keystore password.");
+      throw std::invalid_argument("Invalid SSL keystore password.");
     }
     if (sslctx->certificate(privkeyfile) != 0) {
-      throw SslException("Failed to read SSL certificate.");
+      throw std::invalid_argument("Failed to read SSL certificate.");
     }
     if (::SSL_CTX_use_certificate_chain_file(sslctx->context(), privkeyfile) <=
         0) {
-      throw SslException("Failed to read SSL certificate chain.");
+      throw std::invalid_argument("Failed to read SSL certificate chain.");
     }
     SSLImpl::s_initialized = true;
   }