tlsopensslbase.h
/*
Copyright (c) 2009-2023 by Jakob Schröter <js@camaya.net>
This file is part of the gloox library. http://camaya.net/gloox
This software is distributed under a license. The full license
agreement can be found in the file LICENSE in this distribution.
This software may not be copied, modified, sold or distributed
other than expressed in the named license agreement.
This software is distributed without any warranty.
*/
#ifndef TLSOPENSSLBASE_H__
#define TLSOPENSSLBASE_H__
#include "tlsbase.h"
#include "config.h"
#ifdef HAVE_OPENSSL
#include <openssl/ssl.h>
namespace gloox
{
class OpenSSLBase : public TLSBase
{
public:
OpenSSLBase( TLSHandler* th, const std::string& server = EmptyString );
virtual ~OpenSSLBase();
// reimplemented from TLSBase
virtual bool init( const std::string& clientKey = EmptyString,
const std::string& clientCerts = EmptyString,
const StringList& cacerts = StringList() );
// reimplemented from TLSBase
virtual bool encrypt( const std::string& data );
// reimplemented from TLSBase
virtual int decrypt( const std::string& data );
// reimplemented from TLSBase
virtual void cleanup();
// reimplemented from TLSBase
virtual bool handshake();
// reimplemented from TLSBase
virtual void setCACerts( const StringList& cacerts );
// reimplemented from TLSBase
virtual void setClientCert( const std::string& clientKey, const std::string& clientCerts );
protected:
virtual bool setType() = 0;
virtual int handshakeFunction() = 0;
SSL* m_ssl;
SSL_CTX* m_ctx;
BIO* m_ibio;
BIO* m_nbio;
private:
void pushFunc();
virtual bool privateInit() { return true; }
enum TLSOperation
{
TLSHandshake,
TLSWrite,
TLSRead
};
void doTLSOperation( TLSOperation op );
int ASN1Time2UnixTime( ASN1_TIME* time );
std::string m_recvBuffer;
std::string m_sendBuffer;
char* m_buf;
const int m_bufsize;
};
}
#endif // HAVE_OPENSSL
#endif // TLSOPENSSLBASE_H__
gloox::OpenSSLBase::encrypt
virtual bool encrypt(const std::string &data)
Definition tlsopensslbase.cpp:97
gloox::OpenSSLBase::setCACerts
virtual void setCACerts(const StringList &cacerts)
Definition tlsopensslbase.cpp:125
gloox::OpenSSLBase::handshake
virtual bool handshake()
Definition tlsopensslbase.cpp:270
gloox::OpenSSLBase::cleanup
virtual void cleanup()
Definition tlsopensslbase.cpp:160
gloox::OpenSSLBase::setClientCert
virtual void setClientCert(const std::string &clientKey, const std::string &clientCerts)
Definition tlsopensslbase.cpp:137
gloox::OpenSSLBase::init
virtual bool init(const std::string &clientKey=EmptyString, const std::string &clientCerts=EmptyString, const StringList &cacerts=StringList())
Definition tlsopensslbase.cpp:53
gloox::OpenSSLBase::OpenSSLBase
OpenSSLBase(TLSHandler *th, const std::string &server=EmptyString)
Definition tlsopensslbase.cpp:36
gloox::OpenSSLBase::~OpenSSLBase
virtual ~OpenSSLBase()
Definition tlsopensslbase.cpp:42
gloox::OpenSSLBase::decrypt
virtual int decrypt(const std::string &data)
Definition tlsopensslbase.cpp:111
gloox::TLSBase::TLSBase
TLSBase(TLSHandler *th, const std::string server)
Definition tlsbase.h:39
gloox::TLSHandler
An interface that allows for interacting with TLS implementations derived from TLSBase.
Definition tlshandler.h:35
gloox
The namespace for the gloox library.
Definition adhoc.cpp:28
gloox::StringList
std::list< std::string > StringList
Definition gloox.h:1251
gloox::EmptyString
const std::string EmptyString
Definition gloox.cpp:124