blob: 0ce0b5e0fe27334b42e7a751bab05936fa5f5be4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
// **********************************************************************
//
// Copyright (c) 2003-present ZeroC, Inc. All rights reserved.
//
// **********************************************************************
#include <IceSSL/PluginI.h>
#include <IceSSL/OpenSSL.h>
#include <IceSSL/OpenSSLEngine.h>
#include <Ice/Initialize.h>
using namespace std;
namespace
{
class PluginI : public IceSSL::PluginI,
public IceSSL::OpenSSL::Plugin
{
public:
PluginI(const Ice::CommunicatorPtr&);
virtual Ice::Long getOpenSSLVersion() const;
virtual IceSSL::CertificatePtr create(x509_st*) const;
virtual IceSSL::CertificatePtr load(const std::string&) const;
virtual IceSSL::CertificatePtr decode(const std::string&) const;
virtual void setContext(SSL_CTX*);
virtual SSL_CTX* getContext();
};
} // anonymous namespace end
//
// Plugin implementation.
//
PluginI::PluginI(const Ice::CommunicatorPtr& com) :
IceSSL::PluginI(com, new IceSSL::OpenSSL::SSLEngine(com))
{
}
Ice::Long
PluginI::getOpenSSLVersion() const
{
return SSLeay();
}
IceSSL::CertificatePtr
PluginI::create(x509_st* cert) const
{
return IceSSL::OpenSSL::Certificate::create(cert);
}
IceSSL::CertificatePtr
PluginI::load(const std::string& file) const
{
return IceSSL::OpenSSL::Certificate::load(file);
}
IceSSL::CertificatePtr
PluginI::decode(const std::string& encoding) const
{
return IceSSL::OpenSSL::Certificate::load(encoding);
}
void
PluginI::setContext(SSL_CTX* context)
{
IceSSL::OpenSSL::SSLEngine* engine = dynamic_cast<IceSSL::OpenSSL::SSLEngine*>(_engine.get());
assert(engine);
engine->context(context);
}
SSL_CTX*
PluginI::getContext()
{
IceSSL::OpenSSL::SSLEngine* engine = dynamic_cast<IceSSL::OpenSSL::SSLEngine*>(_engine.get());
assert(engine);
return engine->context();
}
#ifdef _WIN32
//
// Plug-in factory function.
//
extern "C" ICESSL_OPENSSL_API Ice::Plugin*
createIceSSLOpenSSL(const Ice::CommunicatorPtr& communicator, const string& /*name*/, const Ice::StringSeq& /*args*/)
{
return new PluginI(communicator);
}
namespace Ice
{
ICESSL_OPENSSL_API void
registerIceSSLOpenSSL(bool loadOnInitialize)
{
Ice::registerPluginFactory("IceSSL", createIceSSLOpenSSL, loadOnInitialize);
}
}
#else
extern "C" ICESSL_API Ice::Plugin*
createIceSSL(const Ice::CommunicatorPtr& communicator, const string& /*name*/, const Ice::StringSeq& /*args*/)
{
return new PluginI(communicator);
}
//
// The following functions are defined only when OpenSSL is the default
// implementation. In Windows the default implementation is always
// SChannel.
//
IceSSL::CertificatePtr
IceSSL::Certificate::load(const std::string& file)
{
return IceSSL::OpenSSL::Certificate::load(file);
}
IceSSL::CertificatePtr
IceSSL::Certificate::decode(const std::string& encoding)
{
return IceSSL::OpenSSL::Certificate::decode(encoding);
}
#endif
|