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 secure * | client_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.
|
enum | path_t { SYSTEM_CERTIFICATES,
SYSTEM_KEYS
} |
| Path types to retrieve.
|
typedef secure * | server_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, char *ciphers) |
| Assign a non-default cipher to the context.
|
static client_t | client (char *authority=((void *) 0)) |
| Create an anonymous client context with an optional authority to validate.
|
template<typename T > |
static void | erase (T *object) |
static bool | fips (char *program=((void *) 0)) |
| Initialize secure stack with fips support.
|
static bool | init (char *program=((void *) 0)) |
| Initialize secure stack for first use, and report if SSL support is compiled in.
|
static int | oscerts (char *path) |
| Copy system certificates to a local path.
|
static String | path (path_t id) |
| Get a certificate path.
|
static server_t | server (char *authority=((void *) 0)) |
| Create a sever context.
|
static client_t | user (char *authority) |
| Create a peer user client context.
|
static void | uuid (char *string) |
| Create 36 character traditional version 1 uuid.
|
static String | uuid (void) |
static error_t | verify (session_t session, char *peername=((void *) 0)) |
| 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.nosp@m.@gnu.nosp@m.telep.nosp@m.hony.nosp@m..org
Definition at line 62 of file secure.h.
Member Function Documentation
static void ucommon::secure::cipher |
( |
secure * |
context, |
|
|
char * |
ciphers |
|
) |
| |
|
static |
Assign a non-default cipher to the context.
- Parameters:
-
context | to set cipher for. |
ciphers | to set. |
static client_t ucommon::secure::client |
( |
char * |
authority = ((void *) 0) | ) |
|
|
static |
Create an anonymous client context with an optional authority to validate.
- Parameters:
-
authority | path to use or NULL if none. |
- Returns:
- a basic client security context.
error_t ucommon::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 197 of file secure.h.
static bool ucommon::secure::fips |
( |
char * |
program = ((void *) 0) | ) |
|
|
static |
Initialize secure stack with fips support.
If fips support is not successfully enabled, the secure stack is also not initialized. Hence init() can be used for non-fips certified operation if fips fails.
- Parameters:
-
program | name we are initializing for. |
- Returns:
- true if fips support enabled and stack initialized.
static bool ucommon::secure::init |
( |
char * |
program = ((void *) 0) | ) |
|
|
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:
-
program | name we are initializing for. |
- Returns:
- true if ssl support is available, false if not.
bool ucommon::secure::is |
( |
void |
| ) |
|
|
inline |
Determine if the current security context is valid.
- Returns:
- true if valid, -1 if not.
Definition at line 190 of file secure.h.
static int ucommon::secure::oscerts |
( |
char * |
path | ) |
|
|
static |
Copy system certificates to a local path.
- Parameters:
-
- Returns:
- 0 or error number on failure.
Get a certificate path.
This is used to get directories for application specific certificate stores.
- Parameters:
-
- Returns:
- path string or emptry string if not supported.
static server_t ucommon::secure::server |
( |
char * |
authority = ((void *) 0) | ) |
|
|
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:
-
authority | path to use or NULL if none. |
- Returns:
- a security context that is cast from derived library.
static client_t ucommon::secure::user |
( |
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:
-
static void ucommon::secure::uuid |
( |
char * |
string | ) |
|
|
static |
Create 36 character traditional version 1 uuid.
- Parameters:
-
string | to write uuid into, must be 37 bytes or more. |
static error_t ucommon::secure::verify |
( |
session_t |
session, |
|
|
char * |
peername = ((void *) 0) |
|
) |
| |
|
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:
-
session | that is connected. |
peername | that we expect. |
- Returns:
- secure error level or secure::OK if none.
The documentation for this class was generated from the following file: