ucommon  7.0.0
About: GNU uCommon C++ is a portable and optimized class framework for writing C++ applications that need to use threads and support concurrent synchronization, and that use sockets, XML parsing, object serialization, thread-optimized string and data structure classes, etc..
  Fossies Dox: ucommon-7.0.0.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

Loading...
Searching...
No Matches
ucommon::sstream Class Reference

Secure socket using std::iostream. More...

#include <secure.h>

Inheritance diagram for ucommon::sstream:
[legend]
Collaboration diagram for ucommon::sstream:
[legend]

Public Member Functions

 sstream (secure::client_t context)
 Construct a ssl client stream. More...
 
 sstream (const TCPServer *server, secure::server_t context, size_t size=536)
 Construct a ssl server stream. More...
 
 ~sstream ()
 Destroy ssl stream. More...
 
void open (const char *host, const char *service, size_t size=536)
 Open a connection to a ssl server. More...
 
void close (void)
 Close a connection with a ssl server. More...
 
void release (void)
 Release all ssl resources. More...
 
int sync () __OVERRIDE
 
void flush (void)
 
secure::cert_t certificate (void) const
 Get peer (x509) certificate for current stream if present. More...
 
bool is_secure (void) const
 Check if ssl session active, otherwise pure tcp. More...
 
bool is_certificate (void) const
 Check if a peer certificate is present. More...
 
bool is_verified (void) const
 Check if peer certificate is verified through an authority. More...
 
bool is_signed (void) const
 Check if peer certificate is present and at least self-signed. More...
 
- Public Member Functions inherited from ucommon::tcpstream
 tcpstream (const tcpstream &copy)
 Copy constructor... More...
 
 tcpstream (const TCPServer *server, unsigned segsize=536, timeout_t timeout=0)
 Create a stream from an existing tcp listener. More...
 
 tcpstream (int family=PF_INET, timeout_t timeout=0)
 Create an unconnected tcp stream object that is idle until opened. More...
 
 tcpstream (Socket::address &address, unsigned segsize=536, timeout_t timeout=0)
 A convenience constructor that creates a connected tcp stream directly from an address. More...
 
virtual ~tcpstream ()
 Destroy a tcp stream. More...
 
 operator bool () const
 See if stream connection is active. More...
 
bool operator! () const
 See if stream is disconnected. More...
 
void open (Socket::address &address, unsigned segment=536)
 Open a stream connection to a tcp service. More...
 
void open (const char *host, const char *service, unsigned segment=536)
 Open a stream connectoion to a host and service. More...
 
void close (void)
 Close an active stream connection. More...
 
- Public Member Functions inherited from ucommon::StreamBuffer
int sync (void)
 Flush the stream input and output buffers, writes pending output. More...
 
bool is_open (void) const
 
 operator bool () const
 
bool operator! () const
 

Protected Member Functions

ssize_t _write (const char *address, size_t size) __OVERRIDE
 
ssize_t _read (char *address, size_t size) __OVERRIDE
 
bool _wait (void) __OVERRIDE
 
- Protected Member Functions inherited from ucommon::tcpstream
virtual ssize_t _read (char *buffer, size_t size)
 
virtual ssize_t _write (const char *buffer, size_t size)
 
virtual bool _wait (void)
 
void release (void)
 Release the tcp stream and destroy the underlying socket. More...
 
int underflow (void) __OVERRIDE
 This streambuf method is used to load the input buffer through the established tcp socket connection. More...
 
int overflow (int ch) __OVERRIDE
 This streambuf method is used to write the output buffer through the established tcp connection. More...
 
socket_t getsocket (void) const
 
- Protected Member Functions inherited from ucommon::StreamBuffer
 StreamBuffer ()
 
int uflow () __OVERRIDE
 This streambuf method is used for doing unbuffered reads through the establish tcp socket connection when in interactive mode. More...
 
void release (void)
 
void allocate (size_t size)
 

Protected Attributes

secure::session_t ssl
 
secure::bufio_t bio
 
secure::cert_t cert
 
secure::verify_t verified
 
bool server
 
- Protected Attributes inherited from ucommon::tcpstream
socket_t so
 
timeout_t timeout
 
- Protected Attributes inherited from ucommon::StreamBuffer
size_t bufsize
 
char * gbuf
 
char * pbuf
 

Private Member Functions

 __DELETE_COPY (sstream)
 

Detailed Description

Secure socket using std::iostream.

Being based on tcpstream, it also inherits the character protocol. If no context is given or the handshake fails, then the stream defaults to insecure TCP connection behavior.

Author
David Sugar dyfet.nosp@m.@gnu.nosp@m.telep.nosp@m.hony.nosp@m..org

Definition at line 908 of file secure.h.

Constructor & Destructor Documentation

◆ sstream() [1/2]

ucommon::sstream::sstream ( secure::client_t  context)

Construct a ssl client stream.

The context will be loaded with relevant certificates from secure::client().

Parameters
contextto use

Definition at line 25 of file sstream.cpp.

References bio, cert, ucommon::secure::NONE, server, ucommon::__context::session(), ssl, and verified.

Here is the call graph for this function:

◆ sstream() [2/2]

ucommon::sstream::sstream ( const TCPServer server,
secure::server_t  context,
size_t  size = 536 
)

Construct a ssl server stream.

The context will be loaded with relevant certificates from secure::server().

Parameters
serverinstance of tcp socket.
contextto use.
sizeof streaming buffer.

Definition at line 35 of file sstream.cpp.

References bio, cert, ucommon::StreamBuffer::is_open(), ucommon::secure::NONE, result(), server, ucommon::__context::session(), ucommon::tcpstream::so, ssl, and verified.

Here is the call graph for this function:

◆ ~sstream()

ucommon::sstream::~sstream ( )

Destroy ssl stream.

Clean up any resources used.

Definition at line 56 of file sstream.cpp.

References release().

Here is the call graph for this function:

Member Function Documentation

◆ __DELETE_COPY()

ucommon::sstream::__DELETE_COPY ( sstream  )
private

◆ _read()

ssize_t ucommon::sstream::_read ( char *  address,
size_t  size 
)
protectedvirtual

Reimplemented from ucommon::tcpstream.

Definition at line 112 of file sstream.cpp.

References ucommon::tcpstream::_read(), bio, and ssl.

Here is the call graph for this function:

◆ _wait()

bool ucommon::sstream::_wait ( void  )
protectedvirtual

Reimplemented from ucommon::tcpstream.

Definition at line 120 of file sstream.cpp.

References ucommon::tcpstream::_wait(), and ssl.

Here is the call graph for this function:

◆ _write()

ssize_t ucommon::sstream::_write ( const char *  address,
size_t  size 
)
protectedvirtual

Reimplemented from ucommon::tcpstream.

Definition at line 104 of file sstream.cpp.

References ucommon::tcpstream::_write(), bio, and ssl.

Here is the call graph for this function:

◆ certificate()

secure::cert_t ucommon::sstream::certificate ( void  ) const
inline

Get peer (x509) certificate for current stream if present.

Returns
certificate of peer or nullptr if none.

Definition at line 976 of file secure.h.

◆ close()

void ucommon::sstream::close ( void  )

Close a connection with a ssl server.

Definition at line 80 of file sstream.cpp.

References bio, ucommon::tcpstream::close(), server, and ssl.

Referenced by open(), and release().

Here is the call graph for this function:

◆ flush()

void ucommon::sstream::flush ( void  )
inline

Definition at line 968 of file secure.h.

Referenced by main().

◆ is_certificate()

bool ucommon::sstream::is_certificate ( void  ) const
inline

Check if a peer certificate is present.

Returns
true if peer certificate.

Definition at line 992 of file secure.h.

Referenced by main().

◆ is_secure()

bool ucommon::sstream::is_secure ( void  ) const
inline

Check if ssl session active, otherwise pure tcp.

Returns
true if ssl session.

Definition at line 984 of file secure.h.

◆ is_signed()

bool ucommon::sstream::is_signed ( void  ) const
inline

Check if peer certificate is present and at least self-signed.

Returns
true if signed or verified peer.

Definition at line 1008 of file secure.h.

References verified.

◆ is_verified()

bool ucommon::sstream::is_verified ( void  ) const
inline

Check if peer certificate is verified through an authority.

Returns
true if verified peer.

Definition at line 1000 of file secure.h.

References verified.

Referenced by main().

◆ open()

void ucommon::sstream::open ( const char *  host,
const char *  service,
size_t  size = 536 
)

Open a connection to a ssl server.

Parameters
hostname to connect with.
serviceid to connect to.
sizeof stream buffer to use.

Definition at line 61 of file sstream.cpp.

References bio, ucommon::StreamBuffer::bufsize, close(), ucommon::StreamBuffer::is_open(), ucommon::tcpstream::open(), result(), server, ucommon::tcpstream::so, and ssl.

Referenced by main().

Here is the call graph for this function:

◆ release()

void ucommon::sstream::release ( void  )

Release all ssl resources.

Definition at line 93 of file sstream.cpp.

References close(), server, and ssl.

Referenced by ~sstream().

Here is the call graph for this function:

◆ sync()

int ucommon::sstream::sync ( void  )

Definition at line 129 of file sstream.cpp.

References ucommon::StreamBuffer::sync().

Here is the call graph for this function:

Member Data Documentation

◆ bio

secure::bufio_t ucommon::sstream::bio
protected

Definition at line 915 of file secure.h.

Referenced by _read(), _write(), close(), open(), and sstream().

◆ cert

secure::cert_t ucommon::sstream::cert
protected

Definition at line 916 of file secure.h.

Referenced by sstream().

◆ server

bool ucommon::sstream::server
protected

Definition at line 918 of file secure.h.

Referenced by close(), open(), release(), and sstream().

◆ ssl

secure::session_t ucommon::sstream::ssl
protected

Definition at line 914 of file secure.h.

Referenced by _read(), _wait(), _write(), close(), open(), release(), and sstream().

◆ verified

secure::verify_t ucommon::sstream::verified
protected

Definition at line 917 of file secure.h.

Referenced by sstream().


The documentation for this class was generated from the following files: