#include <Pt/Ssl/StreamBuffer.h>
SSL stream buffer. More...
Inherits BasicStreamBuffer< char >.
Public Member Functions | |
| StreamBuffer (std::size_t bufferSize=1024) | |
| Creates a closed SSL stream buffer. | |
| StreamBuffer (Context &ctx, std::ios &ios, OpenMode mode, std::size_t bufferSize=1024) | |
| Creates an SSL stream buffer and opens it. | |
| virtual | ~StreamBuffer () |
| Destructor. | |
| void | open (Context &ctx, std::ios &ios, OpenMode mode) |
| Opens the stream buffer on ios using ctx and mode. | |
| void | setPeerName (const std::string &peerName) |
| Sets the name expected in the peer certificate. | |
| const char * | currentCipher () const |
| Returns the cipher in use, or a placeholder if not connected. | |
| void | close () |
| Closes the stream buffer without a TLS shutdown. | |
| bool | isConnected () const |
| Returns true if the handshake has completed. | |
| bool | writeHandshake () |
| Writes a handshake message to the underlying stream. More... | |
| bool | readHandshake (std::streamsize maxRead=0) |
| Reads a handshake message from the underlying stream. More... | |
| bool | shutdown () |
| Completes or starts the TLS shutdown. More... | |
| bool | isShutdown () const |
| Returns true if a shutdown alert was received. | |
| bool | isClosed () const |
| Returns true if the connection was closed prematurely. | |
| std::streamsize | import (std::streamsize maxImport=0) |
| Decrypts available data from the underlying stream. More... | |
| std::streamsize | speekn (char *buffer, std::streamsize size) |
| Peek data in stream. | |
| std::streamsize | out_avail () |
| Returns the number of characters buffered for output. | |
Protected Member Functions | |
| virtual std::streamsize | showfull () |
| Returns the number of characters buffered for output. | |
StreamBuffer is the streambuf that implements the secure connection the group described. IOStream holds one and forwards handshake, import, and shutdown to it. Construct this type directly when the caller already works with a std::streambuf, or when the expected peer name must be set.
setPeerName() is the name expected in the peer certificate. It may be called before or after open(); an open connection receives the name immediately. import() returns the number of bytes consumed from the underlying stream. readHandshake() and writeHandshake() are the same non-blocking handshake as on IOStream. currentCipher() is the cipher in use, or a placeholder when no connection is open.
The example opens a client buffer and sets the name that must appear in the peer certificate.
| bool writeHandshake | ( | ) |
Returns true if handshake data was written, false otherwise.
| %HandshakeFailed | if the handshake cannot complete. |
| %SslError | if the stream is not open. |
| bool readHandshake | ( | std::streamsize | maxRead = 0 | ) |
Returns true if more handshake data needs to be read, false otherwise.
| %HandshakeFailed | if the handshake cannot complete. |
| %SslError | if the stream is not open. |
| bool shutdown | ( | ) |
Returns true if the shutdown completed.
| %SslError | if the shutdown fails. |
| std::streamsize import | ( | std::streamsize | maxImport = 0 | ) |
Returns the number of bytes consumed from the underlying stream. Call isShutdown() to find out if a shutdown alert was received.