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/Filter.hpp>
30 #include <RCF/Export.hpp>
32 typedef struct ssl_st SSL;
33 typedef struct ssl_ctx_st SSL_CTX;
34 typedef struct x509_st X509;
45 class OpenSslEncryptionFilter;
46 class OpenSslEncryptionFilterImpl;
48 typedef boost::function1<bool, Certificate *> CertificateValidationCb;
51 class RCF_EXPORT PemCertificate :
public Certificate
58 PemCertificate(
const std::string & pathToCert,
const std::string & password =
"");
64 friend class OpenSslEncryptionFilter;
65 friend class OpenSslEncryptionFilterFactory;
67 std::string mPathToCert;
68 std::string mPassword;
72 class OpenSslCryptoDll;
75 class RCF_EXPORT X509Certificate :
public Certificate
81 virtual CertificateImplementationType _getType()
87 std::string getCertificateName();
90 std::string getIssuerName();
94 X509Certificate(X509 * pX509);
100 OpenSslCryptoDll & mCryptoDll;
104 typedef boost::shared_ptr<X509Certificate> X509CertificatePtr;
108 class RCF_EXPORT OpenSslEncryptionFilter :
public Filter, boost::noncopyable
111 int getFilterId()
const;
115 OpenSslEncryptionFilter(
116 ClientStub * pClientStub,
117 SslRole sslRole = SslClient,
118 unsigned int bioBufferSize = 2048);
120 OpenSslEncryptionFilter(
121 const std::string & certificateFile,
122 const std::string & certificateFilePassword,
123 const std::string & caCertificate,
124 const std::string & ciphers,
125 CertificateValidationCb verifyFunctor,
126 SslRole sslRole = SslClient,
127 unsigned int bioBufferSize = 2048);
130 void read(
const ByteBuffer &byteBuffer, std::size_t bytesRequested);
131 void write(
const std::vector<ByteBuffer> &byteBuffers);
132 void onReadCompleted(
const ByteBuffer &byteBuffer);
133 void onWriteCompleted(std::size_t bytesTransferred);
138 CertificatePtr getPeerCertificate();
141 friend class OpenSslEncryptionFilterImpl;
142 boost::shared_ptr<OpenSslEncryptionFilterImpl> mImplPtr;
145 class OpenSslEncryptionFilterFactory :
public FilterFactory
148 OpenSslEncryptionFilterFactory();
150 FilterPtr createFilter(RcfServer & server);
160 #endif // ! INCLUDE_RCF_OPENSSLENCRYPTIONFILTER_HPP