UCommon
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes
ucc::secure Class Reference

Common secure socket support. More...

#include <secure.h>

Public Types

typedef void * bufio_t
 Convenience type to represent a secure socket buf i/o stream.
typedef secureclient_t
 Convenience type to represent a security context.
enum  error_t {
  OK = 0, INVALID, MISSING_CERTIFICATE, MISSING_PRIVATEKEY,
  INVALID_CERTIFICATE, INVALID_AUTHORITY, INVALID_PEERNAME, INVALID_CIPHER
}
 Different error states of the security context.
typedef secureserver_t
typedef void * session_t
 Convenience type to represent a secure socket session.

Public Member Functions

error_t err (void)
 Get last error code associated with the security context.
bool is (void)
 Determine if the current security context is valid.
virtual ~secure ()
 This is derived in different back-end libraries, and will be used to clear certificate credentials.

Static Public Member Functions

static void cipher (secure *context, const char *ciphers)
 Assign a non-default cipher to the context.
static client_t client (const char *authority=NULL)
 Create an anonymous client context with an optional authority to validate.
static bool init (const char *program=NULL)
 Initialize secure stack for first use, and report if SSL support is compiled in.
static server_t server (const char *authority=NULL)
 Create a sever context.
static client_t user (const char *authority)
 Create a peer user client context.
static String uuid (void)
static void uuid (char *string)
 Create 36 character traditional version 1 uuid.
static error_t verify (session_t session, const char *peername=NULL)
 Verify a certificate chain through your certificate authority.

Protected Attributes

error_t error
 Last error flagged for this context.

Detailed Description

Common secure socket support.

This offers common routines needed for secure/ssl socket support code.

Author:
David Sugar <dyfet@gnutelephony.org>

Definition at line 62 of file secure.h.


Member Function Documentation

static void ucc::secure::cipher ( secure context,
const char *  ciphers 
) [static]

Assign a non-default cipher to the context.

Parameters:
contextto set cipher for.
ciphersto set.
static client_t ucc::secure::client ( const char *  authority = NULL) [static]

Create an anonymous client context with an optional authority to validate.

Parameters:
authoritypath to use or NULL if none.
Returns:
a basic client security context.
error_t ucc::secure::err ( void  ) [inline]

Get last error code associated with the security context.

Returns:
last error code or 0/OK if none.

Definition at line 167 of file secure.h.

static bool ucc::secure::init ( const char *  program = NULL) [static]

Initialize secure stack for first use, and report if SSL support is compiled in.

This allows a program name to be passed, which may be used for some proxy systems.

Parameters:
programname we are initializing for.
Returns:
true if ssl support is available, false if not.
bool ucc::secure::is ( void  ) [inline]

Determine if the current security context is valid.

Returns:
true if valid, -1 if not.

Definition at line 160 of file secure.h.

static server_t ucc::secure::server ( const char *  authority = NULL) [static]

Create a sever context.

The certificate file used will be based on the init() method name. This may often be /etc/ssl/certs/initname.pem. Similarly, a matching private key certificate will also be loaded. An optional certificate authority document can be used when we are establishing a service which ssl clients have their own certificates.

Parameters:
authoritypath to use or NULL if none.
Returns:
a security context that is cast from derived library.
static client_t ucc::secure::user ( const char *  authority) [static]

Create a peer user client context.

This assumes a user certificate in ~/.ssl/certs and the user private key in ~/.ssl/private. The path to an authority is also sent.

Parameters:
authoritypath to use.
static void ucc::secure::uuid ( char *  string) [static]

Create 36 character traditional version 1 uuid.

Parameters:
stringto write uuid into, must be 37 bytes or more.
static error_t ucc::secure::verify ( session_t  session,
const char *  peername = NULL 
) [static]

Verify a certificate chain through your certificate authority.

This uses the ca loaded as an optional argument for client and server. Optionally the hostname of the connection can also be verified by pulling the peer certificate.

Parameters:
sessionthat is connected.
peernamethat we expect.
Returns:
secure error level or secure::OK if none.

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