diff options
Diffstat (limited to 'cpp/src/Ice/SslConnector.cpp')
-rw-r--r-- | cpp/src/Ice/SslConnector.cpp | 77 |
1 files changed, 75 insertions, 2 deletions
diff --git a/cpp/src/Ice/SslConnector.cpp b/cpp/src/Ice/SslConnector.cpp index 7ffb7f0c797..dc819faa798 100644 --- a/cpp/src/Ice/SslConnector.cpp +++ b/cpp/src/Ice/SslConnector.cpp @@ -6,20 +6,45 @@ // // All Rights Reserved // -// ********************************************************************** +// **********************************************************************
+#ifdef WIN32
+#pragma warning(disable:4786)
+#endif
+#ifdef SSL_EXTENSION
+#include <Ice/SslFactory.h>
+#include <Ice/SslSystem.h>
+#endif
+
#include <Ice/SslConnector.h> #include <Ice/SslTransceiver.h> #include <Ice/Instance.h> #include <Ice/TraceLevels.h> #include <Ice/Logger.h> #include <Ice/Network.h> +#include <Ice/Properties.h>
#include <Ice/Exception.h> +
+#ifdef SSL_EXTENSION
+#include <Ice/SslException.h>
+#endif
+
+#include <sstream>
using namespace std; using namespace Ice; using namespace IceInternal; +using std::ostringstream;
+using std::string;
+
+#ifdef SSL_EXTENSION
+using IceSecurity::Ssl::Connection;
+using IceSecurity::Ssl::Factory;
+using IceSecurity::Ssl::System;
+using IceSecurity::Ssl::ShutdownException; +#endif
+
TransceiverPtr IceInternal::SslConnector::connect(int timeout) { @@ -40,7 +65,55 @@ IceInternal::SslConnector::connect(int timeout) _logger->trace(_traceLevels->networkCat, s.str()); } - return new SslTransceiver(_instance, fd); +#ifdef SSL_EXTENSION
+ // This is the Ice SSL Configuration File on which we will base
+ // all connections in this communicator.
+ string configFile = _instance->properties()->getProperty("Ice.Ssl.Config");
+
+ // Get an instance of the SslOpenSSL singleton.
+ System* sslSystem = Factory::getSystem(configFile);
+
+ if (!sslSystem->isTraceSet())
+ {
+ sslSystem->setTrace(_traceLevels);
+ }
+
+ if (!sslSystem->isLoggerSet())
+ {
+ sslSystem->setLogger(_logger);
+ }
+
+ // Initialize the server (if needed)
+ if (!sslSystem->isConfigLoaded())
+ {
+ sslSystem->loadConfig();
+ }
+ + Connection* sslConnection = 0;
+
+ try
+ {
+ sslConnection = sslSystem->createClientConnection(fd);
+ }
+ catch (...)
+ {
+ Factory::releaseSystem(sslSystem);
+ sslSystem = 0;
+
+ // Shutdown the connection.
+ throw;
+ }
+
+ TransceiverPtr transPtr = new SslTransceiver(_instance, fd, sslConnection);
+
+ Factory::releaseSystem(sslSystem);
+ sslSystem = 0;
+ +#else
+ TransceiverPtr transPtr = new SslTransceiver(_instance, fd);
+#endif
+
+ return transPtr;
} string |