00001
00002
00003
00004
00005
00006
00007 #ifndef __WVSSLSTREAM_H
00008 #define __WVSSLSTREAM_H
00009
00010 #include "wvstreamclone.h"
00011 #include "wvfdstream.h"
00012 #include "wvlog.h"
00013 #include "wvcallback.h"
00014
00015 struct ssl_st;
00016 struct ssl_ctx_st;
00017 struct ssl_method_st;
00018
00019 typedef struct ssl_ctx_st SSL_CTX;
00020 typedef struct ssl_st SSL;
00021 typedef struct ssl_method_st SSL_METHOD;
00022
00023 class WvX509Mgr;
00024
00025 typedef WvCallback<bool, WvX509Mgr*> WvSSLValidateCallback;
00026
00032 class WvSSLStream : public WvStreamClone
00033 {
00034 public:
00040 WvSSLStream(IWvStream *_slave, WvX509Mgr *x509 = NULL,
00041 WvSSLValidateCallback _vcb = 0, bool _is_server = false);
00042
00044 virtual ~WvSSLStream();
00045
00046 virtual bool pre_select(SelectInfo &si);
00047 virtual bool post_select(SelectInfo &si);
00048
00049 virtual void close();
00050
00051 virtual bool isok() const;
00052
00053 protected:
00055 SSL_CTX *ctx;
00056
00061 SSL *ssl;
00062
00067 SSL_METHOD *meth;
00068
00073 virtual size_t uwrite(const void *buf, size_t len);
00074
00079 virtual size_t uread(void *buf, size_t len);
00080
00081 private:
00086 volatile bool sslconnected;
00087
00089 void setconnected(bool conn);
00090
00092 bool is_server;
00093
00095 WvSSLValidateCallback vcb;
00096
00098 WvLog debug;
00099
00108 WvInPlaceBuf write_bouncebuf;
00109 size_t write_eat;
00110
00112 WvInPlaceBuf read_bouncebuf;
00113 bool read_pending;
00114
00116 WvDynBuf unconnected_buf;
00117
00119 void printerr(WvStringParm func);
00120
00121 };
00122
00123 #endif // __WVSSLSTREAM_H
00124