Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

dsSSLSocket.h

Go to the documentation of this file.
00001 /* 
00002  * $Id: dsSSLSocket.h,v 1.7 2004/05/19 15:38:58 dsamersoff Exp $
00003  */
00004 #ifndef dsSSLSocket_h 
00005 #define dsSSLSocket_h 
00006 
00007 #ifdef HAVE_CONFIG_H
00008 # include <config.h>
00009 #endif
00010 
00011 #include <stdlib.h>
00012 
00013 #ifdef HAVE_UNISTD_H
00014 # include <unistd.h>
00015 #endif
00016 
00017 #include <openssl/crypto.h>
00018 #include <openssl/ssl.h>
00019 #include <openssl/err.h>
00020 
00021 
00022 #include <dsSmartException.h>
00023 #include <dsSocket.h>
00024 #include <dsform.h>
00025 #include <dsutil.h>
00026 
00027 #define NO_FLAGS 0                                                              // No special flags specified
00028 
00029 /* I have to change some functions to transparent handle ssl errors   
00030  * no support for syslog here
00031  */
00032  
00033 class  dsSSLException : public dsSmartException
00034 { 
00035 public:
00036      dsSSLException(){ }
00037 
00038      dsSSLException(const char *format, ... )
00039       {     va_list ap; 
00040             va_start(ap, format); 
00041              SSL_fire((char *) format, ap); 
00042             va_end(ap); 
00043      }
00044             
00045      void SSL_fire(char *format, va_list ap )
00046      {
00047          _tag    << "dsSSLSocket";
00048          
00049          unsigned long err = ERR_get_error();
00050          _message << '(';
00051          _message << ERR_error_string(err,0);
00052          _message << ')';
00053          dsvform( _message, format, ap);
00054      }
00055 };
00056 
00057 
00062 class dsSSLSocket : public dsSocket
00063 {
00064     SSL_CTX* ctx;
00065     SSL*     ssl;
00066     SSL_METHOD *meth;
00067     X509*    server_cert;
00068 
00069 protected:
00070 
00071     virtual size_t __read(char *buf,  size_t bytes);
00072     virtual size_t __write(const char *ptr, size_t bytes);
00073 
00074 public:
00075   
00076     dsSSLSocket(char *host, int port);   
00077     dsSSLSocket();
00078    ~dsSSLSocket();
00079 
00080 
00081   virtual void Connect(char *host, int port, int proto = IPPROTO_TCP);
00082   virtual void Close();
00083 
00084   X509*  getPeerCert();
00085   
00086 };
00087 
00088 #endif

Generated on Mon May 16 18:26:58 2005 for libdms4 by doxygen1.3-rc2