From 52767927889b305fe18b28ddfc5351f08b703d2d Mon Sep 17 00:00:00 2001 From: m0gg Date: Mon, 6 Mar 2006 13:37:38 +0000 Subject: Various changes see ChangeLog --- nanohttp/nanohttp-ssl.h | 99 ++++++++++++++++++++----------------------------- 1 file changed, 41 insertions(+), 58 deletions(-) (limited to 'nanohttp/nanohttp-ssl.h') diff --git a/nanohttp/nanohttp-ssl.h b/nanohttp/nanohttp-ssl.h index 1cdafb2..82a7db7 100644 --- a/nanohttp/nanohttp-ssl.h +++ b/nanohttp/nanohttp-ssl.h @@ -18,68 +18,53 @@ /* * Author: Matt Campbell - * Contrib: - * Descrip: Common ssl routines */ - -/* Do enter only if --with-ssl was specified by the configure script */ -#ifdef HAVE_SSL - -#ifdef TRU64 -#include -typedef unsigned int uint32_t; -#endif - #ifndef __NANOHTTP_SSL_H_ #define __NANOHTTP_SSL_H_ -#include - -#ifdef WIN32 -typedef unsigned int uint32_t; -#else -#include +#ifdef HAVE_CONFIG_H +#include #endif -#define SSL_SERVER 0 -#define SSL_CLIENT 1 - -#define CERT_SUBJECT 0 -#define CERT_ISSUER 1 - -typedef struct Con -{ - SSL *ssl; - int sock; -} Con; +#ifdef HAVE_SSL -/* - * Callback for password checker - */ +#ifdef HAVE_OPENSSL_SSL_H +#include +#endif #ifdef __cplusplus extern "C" { #endif -//static int pw_cb(char* buf, int num, int rwflag, void *userdata); +/** + * + * Initialization and shutdown of the SSL module + * + */ +herror_t hssl_module_init(int argc, char **argv); +void hssl_module_destroy(void); -/* - * Start the ssl library +/** + * + * Socket initialization and shutdown + * */ -void start_ssl( void ); +herror_t hssl_client_ssl(hsocket_t *sock); +herror_t hssl_server_ssl(hsocket_t *sock); + +void hssl_cleanup(hsocket_t *sock); + /* - * Initialize the context + * Callback for password checker */ - -SSL_CTX *initialize_ctx(const char *keyfile, - const char *password, - const char *calist); +//static int pw_cb(char* buf, int num, int rwflag, void *userdata); /* * Quick function for verifying a portion of the cert * nid is any NID_ defined in * returns non-zero if everything went ok */ +#define CERT_SUBJECT 1 int verify_sn(X509 * cert, int who, int nid, char *str); @@ -95,33 +80,31 @@ int verify_sn(X509 * cert, int who, int nid, char *str); int user_verify(X509 * cert); -/* - * Create the ssl socket and return it - * pass in the context and an open socket - */ +#ifdef __cplusplus +} +#endif -SSL *init_ssl(SSL_CTX * ctx, int sock, int type); +#else /* HAVE_SSL */ -/* - * Close the ssl connection (socket is still left open) - */ +static inline herror_t hssl_module_init(int argc, char **argv) { return H_OK; } +static inline void hssl_module_destroy(void) { return; } -void ssl_cleanup(); +static inline herror_t hssl_client_ssl(hsocket_t *sock) { return H_OK; } +static inline herror_t hssl_server_ssl(hsocket_t *sock) { return H_OK; } -/** - Log funtion to report ssl failures - @param ssl - @param ret - */ -void -log_ssl_error (SSL * ssl, int ret); +static inline void hssl_cleanup(hsocket_t *sock) { return; } -int ssl_checkFatal( SSL *ssl, int status ); +#endif /* HAVE_SSL */ +#ifdef __cplusplus +extern "C" { #endif +herror_t hssl_read(hsocket_t *sock, char *buf, size_t len, size_t *received); +herror_t hssl_write(hsocket_t *sock, const char *buf, size_t len, size_t *sent); + #ifdef __cplusplus } #endif -#endif /* HAVE_SSL */ +#endif -- cgit v1.1-32-gdbae