68 typedef size_t size_type ;
69 typedef ssize_t ssize_type ;
70 enum Result { Result_ok , Result_read , Result_write , Result_error , Result_more } ;
71 typedef void (*LogFn)( int ,
const std::string & ) ;
73 explicit Protocol(
const Profile & , LogFn log_fn ) ;
88 Result
read(
char * buffer , size_type buffer_size_in , ssize_type & data_size_out ) ;
115 Result
write(
const char * buffer , size_type data_size_in , ssize_type & data_size_out ) ;
135 static std::string
str( Result result ) ;
148 void operator=(
const Protocol & ) ;
151 ProtocolImp * m_imp ;
160 explicit Library(
bool active =
true ,
const std::string & extra_config = std::string() ) ;
166 explicit Library(
bool active ,
const std::string & server_key_and_cert_file ,
167 const std::string & server_ca_file ,
const std::string & extra_config = std::string() ) ;
177 void add(
const std::string & profile_name ,
const std::string & key_and_cert_file = std::string() ,
178 const std::string & ca_file = std::string() ,
const std::string & profile_extra_config = std::string() ) ;
198 bool has(
const std::string & profile_name )
const ;
201 const Profile &
profile(
const std::string & profile_name )
const ;
209 static std::string
id() ;
212 static std::string
credit(
const std::string & prefix ,
const std::string & eol ,
const std::string & eot ) ;
216 friend class GSsl::Profile ;
218 void operator=(
const Library & ) ;
219 const LibraryImp & imp()
const ;
static Library * instance()
Returns a pointer to a library object, if any.
Protocol(const Profile &, LogFn log_fn)
Constructor.
An abstract interface for reading and writing from a non-blocking i/o channel.
bool has(const std::string &profile_name) const
Returns true if the named profile has been add()ed.
void add(const std::string &profile_name, const std::string &key_and_cert_file=std::string(), const std::string &ca_file=std::string(), const std::string &profile_extra_config=std::string())
Creates a named Profile object that can be retrieved by profile().
static std::string str(Result result)
Converts a result enumeration into a printable string.
~Library()
Destructor. Cleans up the underlying TLS library.
std::pair< std::string, bool > peerCertificate(int format=0)
Returns the peer certificate and a verified flag.
Library(bool active=true, const std::string &extra_config=std::string())
Constructor.
Result stop()
Initiates the protocol shutdown.
Result accept(G::ReadWrite &io)
Starts the protocol passively (as a server).
Result connect(G::ReadWrite &io)
Starts the protocol actively (as a client).
static std::string credit(const std::string &prefix, const std::string &eol, const std::string &eot)
Returns a library credit string.
const Profile & profile(const std::string &profile_name) const
Returns an opaque reference to the named profile.
Result read(char *buffer, size_type buffer_size_in, ssize_type &data_size_out)
Reads user data into the supplied buffer.
A singleton class for initialising the underlying TLS library.
static std::string id()
Returns a library identifier (typically name and version).
bool enabled() const
Returns true if this is a real TLS library and the constructor's active parameter was set...
Result write(const char *buffer, size_type data_size_in, ssize_type &data_size_out)
Writes user data.