libepp_nicbr
TransportTLSCommon.H
Go to the documentation of this file.
1 /* ${copyright}$ */
2 /* $Id: TransportTLSCommon.H 1086 2010-12-10 13:07:28Z eduardo $ */
7 #ifndef __TRANSPORTTLSCOMMON_H__
8 #define __TRANSPORTTLSCOMMON_H__
9 
10 #include <string>
11 
12 #include <openssl/bio.h>
13 #include <openssl/ssl.h>
14 
15 #include "libepp_nicbr.H"
16 
17 #include "StrUtil.H"
18 
19 using std::string;
20 
21 LIBEPP_NICBR_NS_BEGIN
22 
25 {
26 public:
29 
32 
34 
38  void read(string &xml_payload, const int &timeout = TIMEOUT);
39 
41 
45  void write(const string &xml_payload, const int &timeout = TIMEOUT);
46 
48  void disconnect();
49 
51 
54  string get_openssl_msg() const;
55 
57 
61  long cert_common_name_check(const string &common_name);
62 
65 
68 
69 protected:
71  void seed_prng();
72 
74 
82  static int pem_passwd_cb(char *buf, int size, int rwflag, void *userdata);
83 
85 
90  void setup_context(const string &cert_file,
91  const string &root_ca_file,
92  const string &pem_passphrase = "");
93 
95  void set_non_blocking();
96 
98  BIO *_conn;
99 
101  SSL_CTX *_ssl_ctx;
102 
104  SSL *_ssl;
105 
107  static string _pem_passphrase;
108 
110  static const int TIMEOUT;
111 
114 };
115 
116 LIBEPP_NICBR_NS_END
117 #endif //__TRANSPORTTLSCOMMON_H__
string get_openssl_msg() const
Return the OpenSSL error message.
void enable_cert_common_name_check()
Enables peer's certificate common name check.
bool _cert_common_name_check_enabled
Flag for peer's certificate CN check.
Definition: TransportTLSCommon.H:113
Project defines.
void set_non_blocking()
Set the underlying I/O descriptor as non-blocking.
void read(string &xml_payload, const int &timeout=TIMEOUT)
Read payload from the open connection.
static const int TIMEOUT
Default read/write timeout in seconds.
Definition: TransportTLSCommon.H:110
TransportTLSCommon()
Constructor.
void seed_prng()
Seed OpenSSL pseudo random number generator.
long cert_common_name_check(const string &common_name)
Checks if peer's certificate common name matches string common_name.
SSL * _ssl
SSL object.
Definition: TransportTLSCommon.H:104
BIO * _conn
BIO Socket.
Definition: TransportTLSCommon.H:98
TransportTLSCommon class.
Definition: TransportTLSCommon.H:24
String Manipulation Utilities.
void write(const string &xml_payload, const int &timeout=TIMEOUT)
Write payload to the open connection.
void disconnect()
Close the connection.
~TransportTLSCommon()
Destructor.
SSL_CTX * _ssl_ctx
SSL Context.
Definition: TransportTLSCommon.H:101
void setup_context(const string &cert_file, const string &root_ca_file, const string &pem_passphrase="")
Setup Context for Certificate Validation.
static int pem_passwd_cb(char *buf, int size, int rwflag, void *userdata)
Callback method used by OpenSSL to collect passphrases.
static string _pem_passphrase
pem passphrase
Definition: TransportTLSCommon.H:107
void disable_cert_common_name_check()
Disables peer's certificate common name check.