19 #ifndef INCLUDE_RCF_OPENSSLENCRYPTIONFILTER_HPP
20 #define INCLUDE_RCF_OPENSSLENCRYPTIONFILTER_HPP
25 #include <boost/function.hpp>
26 #include <boost/noncopyable.hpp>
27 #include <boost/shared_ptr.hpp>
29 #include <RCF/Certificate.hpp>
30 #include <RCF/Filter.hpp>
31 #include <RCF/Export.hpp>
33 typedef struct ssl_st SSL;
34 typedef struct ssl_ctx_st SSL_CTX;
35 typedef struct x509_st X509;
46 class OpenSslEncryptionFilter;
47 class OpenSslEncryptionFilterImpl;
49 typedef boost::function1<bool, Certificate *> CertificateValidationCb;
52 class RCF_EXPORT PemCertificate :
public Certificate
59 PemCertificate(
const std::string & pathToCert,
const std::string & password =
"");
65 friend class OpenSslEncryptionFilter;
66 friend class OpenSslEncryptionFilterFactory;
68 std::string mPathToCert;
69 std::string mPassword;
73 class OpenSslCryptoDll;
76 class RCF_EXPORT X509Certificate :
public Certificate
82 virtual CertificateImplementationType _getType()
88 std::string getCertificateName();
91 std::string getIssuerName();
95 X509Certificate(X509 * pX509);
100 OpenSslDll & mSslDll;
101 OpenSslCryptoDll & mCryptoDll;
105 typedef boost::shared_ptr<X509Certificate> X509CertificatePtr;
109 class RCF_EXPORT OpenSslEncryptionFilter :
public Filter, boost::noncopyable
112 int getFilterId()
const;
116 OpenSslEncryptionFilter(
117 ClientStub * pClientStub,
118 SslRole sslRole = SslClient,
119 unsigned int bioBufferSize = 2048);
121 OpenSslEncryptionFilter(
122 const std::string & certificateFile,
123 const std::string & certificateFilePassword,
124 const std::string & caCertificate,
125 const std::string & ciphers,
126 CertificateValidationCb verifyFunctor,
127 SslRole sslRole = SslClient,
128 unsigned int bioBufferSize = 2048);
131 void read(
const ByteBuffer &byteBuffer, std::size_t bytesRequested);
132 void write(
const std::vector<ByteBuffer> &byteBuffers);
133 void onReadCompleted(
const ByteBuffer &byteBuffer);
134 void onWriteCompleted(std::size_t bytesTransferred);
139 CertificatePtr getPeerCertificate();
142 friend class OpenSslEncryptionFilterImpl;
143 boost::shared_ptr<OpenSslEncryptionFilterImpl> mImplPtr;
146 class OpenSslEncryptionFilterFactory :
public FilterFactory
149 OpenSslEncryptionFilterFactory();
151 FilterPtr createFilter(RcfServer & server);
161 #endif // ! INCLUDE_RCF_OPENSSLENCRYPTIONFILTER_HPP