summaryrefslogtreecommitdiff
path: root/cpp/src/IceSSL/ClientContext.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/IceSSL/ClientContext.cpp')
-rw-r--r--cpp/src/IceSSL/ClientContext.cpp81
1 files changed, 81 insertions, 0 deletions
diff --git a/cpp/src/IceSSL/ClientContext.cpp b/cpp/src/IceSSL/ClientContext.cpp
new file mode 100644
index 00000000000..0d05c03eb19
--- /dev/null
+++ b/cpp/src/IceSSL/ClientContext.cpp
@@ -0,0 +1,81 @@
+// **********************************************************************
+//
+// Copyright (c) 2002
+// Mutable Realms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#include <Ice/Logger.h>
+
+#include <IceSSL/Exception.h>
+#include <IceSSL/ClientContext.h>
+#include <IceSSL/SslClientTransceiver.h>
+#include <IceSSL/TraceLevels.h>
+
+using namespace std;
+using namespace Ice;
+
+void
+IceSSL::ClientContext::configure(const GeneralConfig& generalConfig,
+ const CertificateAuthority& certificateAuthority,
+ const BaseCertificates& baseCertificates)
+{
+ Context::configure(generalConfig, certificateAuthority, baseCertificates);
+
+ loadCertificateAuthority(certificateAuthority);
+
+ if(_traceLevels->security >= SECURITY_PROTOCOL)
+ {
+ ostringstream s;
+
+ s << endl;
+ s << "general configuration (client)" << endl;
+ s << "------------------------------" << endl;
+ s << generalConfig << endl << endl;
+
+ s << "certificate authority (client)" << endl;
+ s << "------------------------------" << endl;
+ s << "file: " << certificateAuthority.getCAFileName() << endl;
+ s << "path: " << certificateAuthority.getCAPath() << endl;
+
+ s << "base certificates (client)" << endl;
+ s << "--------------------------" << endl;
+ s << baseCertificates << endl;
+
+ _logger->trace(_traceLevels->securityCat, s.str());
+ }
+}
+
+IceSSL::SslTransceiverPtr
+IceSSL::ClientContext::createTransceiver(int socket, const OpenSSLPluginIPtr& plugin)
+{
+ if(_sslContext == 0)
+ {
+ ContextNotConfiguredException contextEx(__FILE__, __LINE__);
+
+ throw contextEx;
+ }
+
+ SSL* ssl = createSSLConnection(socket);
+ SslTransceiverPtr transceiver = new SslClientTransceiver(plugin, socket, _certificateVerifier, ssl);
+
+ transceiverSetup(transceiver);
+
+ return transceiver;
+}
+
+IceSSL::ClientContext::ClientContext(const TraceLevelsPtr& traceLevels, const LoggerPtr& logger,
+ const PropertiesPtr& properties) :
+ Context(traceLevels, logger, properties)
+{
+ _rsaPrivateKeyProperty = "IceSSL.Client.Overrides.RSA.PrivateKey";
+ _rsaPublicKeyProperty = "IceSSL.Client.Overrides.RSA.Certificate";
+ _dsaPrivateKeyProperty = "IceSSL.Client.Overrides.DSA.PrivateKey";
+ _dsaPublicKeyProperty = "IceSSL.Client.Overrides.DSA.Certificate";
+ _caCertificateProperty = "IceSSL.Client.Overrides.CACertificate";
+ _handshakeTimeoutProperty = "IceSSL.Client.Handshake.ReadTimeout";
+ _passphraseRetriesProperty = "IceSSL.Client.Passphrase.Retries";
+}