00001
00002
00007 #ifndef __TRANSPORTTLSCOMMON_H__
00008 #define __TRANSPORTTLSCOMMON_H__
00009
00010 #include <string>
00011
00012 #include <openssl/bio.h>
00013 #include <openssl/ssl.h>
00014
00015 #include "libepp_nicbr.H"
00016
00017 #include "StrUtil.H"
00018
00019 using std::string;
00020
00021 LIBEPP_NICBR_NS_BEGIN
00022
00024 class TransportTLSCommon
00025 {
00026 public:
00028 TransportTLSCommon();
00029
00031 ~TransportTLSCommon();
00032
00034
00038 void read(string &xml_payload, const int &timeout = TIMEOUT);
00039
00041
00045 void write(const string &xml_payload, const int &timeout = TIMEOUT);
00046
00048
00051 string get_openssl_msg();
00052
00053 protected:
00055 void seed_prng();
00056
00058
00066 static int pem_passwd_cb(char *buf, int size, int rwflag, void *userdata);
00067
00069
00074 void setup_context(const string &cert_file,
00075 const string &root_ca_file,
00076 const string &pem_passphrase = "");
00077
00079 void set_non_blocking();
00080
00082 BIO *_conn;
00083
00085 SSL_CTX *_ssl_ctx;
00086
00088 SSL *_ssl;
00089
00091 static string _pem_passphrase;
00092
00094 static const int TIMEOUT;
00095 };
00096
00097 LIBEPP_NICBR_NS_END
00098 #endif //__TRANSPORTTLSCOMMON_H__