IBR-DTNSuite
0.8
|
A Stream Class that adds Signatures and Encryption through TLS. More...
#include <TLSStream.h>
Public Types | |
typedef std::char_traits< char > | traits |
Public Member Functions | |
TLSStream (std::iostream *stream) | |
The TLSStream Constructor. | |
virtual | ~TLSStream () |
The default Destructor. | |
void | setServer (bool val) |
void | close () |
Closes the TLS Connection. | |
X509 * | activate () |
Static Public Member Functions | |
static void | init (X509 *certificate, EVP_PKEY *privateKey, ibrcommon::File trustedCAPath, bool enableEncryption=false) |
Initializes the TLSStream class. | |
static void | flushInitialization () |
Removes the SSL_CTX to allow a new init() | |
static bool | isInitialized () |
checks if the Class is already initialized. | |
Static Public Attributes | |
static const size_t | BUFF_SIZE = 5120 |
The size of the input and output buffers. | |
Protected Member Functions | |
virtual int | sync () |
virtual traits::int_type | overflow (traits::int_type=traits::eof()) |
virtual traits::int_type | underflow () |
A Stream Class that adds Signatures and Encryption through TLS.
The Stream passes data from and to the underlying Stream unchanged(unencrypted) until activate() is called. init() has to be called before the first usage.
Definition at line 27 of file TLSStream.h.
typedef std::char_traits<char> ibrcommon::TLSStream::traits |
Definition at line 30 of file TLSStream.h.
ibrcommon::TLSStream::TLSStream | ( | std::iostream * | stream | ) |
The TLSStream Constructor.
stream | the underlying Stream to read from / write to |
server | states, if TLS is used in client or server mode (true for server, false for client) |
Definition at line 32 of file TLSStream.cpp.
References BUFF_SIZE.
ibrcommon::TLSStream::~TLSStream | ( | ) | [virtual] |
The default Destructor.
Definition at line 42 of file TLSStream.cpp.
X509 * ibrcommon::TLSStream::activate | ( | ) |
Definition at line 55 of file TLSStream.cpp.
References ibrcommon::iostreamBIO::getBIO(), IBRCOMMON_LOGGER, IBRCOMMON_LOGGER_ENDL, and ibrcommon::Exception::what().
void ibrcommon::TLSStream::close | ( | ) |
Closes the TLS Connection.
Definition at line 347 of file TLSStream.cpp.
References IBRCOMMON_LOGGER_DEBUG, and IBRCOMMON_LOGGER_ENDL.
Referenced by underflow().
void ibrcommon::TLSStream::flushInitialization | ( | ) | [static] |
Removes the SSL_CTX to allow a new init()
Definition at line 328 of file TLSStream.cpp.
void ibrcommon::TLSStream::init | ( | X509 * | certificate, |
EVP_PKEY * | privateKey, | ||
ibrcommon::File | trustedCAPath, | ||
bool | enableEncryption = false |
||
) | [static] |
Initializes the TLSStream class.
certificate | The certificate for the private Key |
privateKey | The private Key to use with openSSL |
trustedCAPath | A directory containing certificates that are trusted. These are also used to build the own certificate chain. |
enableEncryption | True if encryption shall be enabled. Otherwise only authentication is enabled. |
In particular, this function initializes the used openSSL Context. The certificate directory has to hold certificates files with hashed names created by c_rehash (from the openssl library).
Definition at line 237 of file TLSStream.cpp.
References ibrcommon::File::getFiles(), ibrcommon::File::getPath(), IBRCOMMON_LOGGER, IBRCOMMON_LOGGER_ENDL, and ibrcommon::File::isDirectory().
bool ibrcommon::TLSStream::isInitialized | ( | ) | [static] |
checks if the Class is already initialized.
Definition at line 343 of file TLSStream.cpp.
Referenced by dtn::net::TCPConvergenceLayer::componentRun(), dtn::net::TCPConvergenceLayer::open(), and dtn::net::TCPConvergenceLayer::queue().
TLSStream::traits::int_type ibrcommon::TLSStream::overflow | ( | traits::int_type | c = traits::eof() | ) | [protected, virtual] |
Definition at line 189 of file TLSStream.cpp.
References BUFF_SIZE, IBRCOMMON_LOGGER_DEBUG, and IBRCOMMON_LOGGER_ENDL.
Referenced by sync().
void ibrcommon::TLSStream::setServer | ( | bool | val | ) |
If true, set the connection mode to server.
val |
Definition at line 50 of file TLSStream.cpp.
int ibrcommon::TLSStream::sync | ( | ) | [protected, virtual] |
Definition at line 363 of file TLSStream.cpp.
References overflow().
TLSStream::traits::int_type ibrcommon::TLSStream::underflow | ( | ) | [protected, virtual] |
Definition at line 139 of file TLSStream.cpp.
References BUFF_SIZE, close(), IBRCOMMON_LOGGER_DEBUG, and IBRCOMMON_LOGGER_ENDL.
const size_t ibrcommon::TLSStream::BUFF_SIZE = 5120 [static] |
The size of the input and output buffers.
Definition at line 81 of file TLSStream.h.
Referenced by overflow(), TLSStream(), and underflow().