00001
00002
00003
00004 #ifndef __XVR2_NET_SSL_CONTEXT_H__
00005 #define __XVR2_NET_SSL_CONTEXT_H__
00006 #include<xvr2/Net/netdefs.h>
00007 #include<xvr2/Object.h>
00008 #include<xvr2/Net/TCPSocket.h>
00009 #include<xvr2/StringBuffer.h>
00010 #include<xvr2/Net/X509.h>
00011 #include<xvr2/Net/NetworkExceptions.h>
00012
00013 namespace xvr2 {
00014 namespace Net {
00024 class SSLContext:public Object{
00025 private:
00026 static int passwdCB(char *buf,int num, int rwflag, void *userdata);
00027 protected:
00028 void *ctx;
00029 int method;
00030 String keyfile;
00031 void *mydata;
00033 StringBuffer c_list;
00034 X509 *pem;
00035 public:
00038 SSLContext(int _method = SSL_V23);
00039 SSLContext(const String &_keyfile, int _method = SSL_V23);
00040 ~SSLContext();
00044 virtual int passwordCallback(char *buf, int num, int rwflag, void *userdata);
00047 void setUserdata(void *data);
00052 void setPassphrase(const char *passphrase);
00053 void pemCertificateChainFile(const String &chain_file);
00054 void privateKeyfile(const String &file, int type = KEYFILE_PEM);
00055 void rsaPrivateKeyfile(const String &file, int type = KEYFILE_PEM);
00056 void loadVerifyLocations(const String &cafile, const String &capath);
00057 bool privateKeyIsValid();
00058 void *getInternal(){
00059 return ctx;
00060 }
00061 void addCipher(const String &cyp);
00062 const X509 *getX509();
00063 };
00064 }
00065 };
00066
00067
00068 #endif