DRDE/ACTK1_0/session/TLSSocket.hpp

50 lines
966 B
C++
Raw Normal View History

#ifndef __TLS_SOCKET_HPP
#define __TLS_SOCKET_HPP
#include "session/SSLException.hpp"
#include <openssl/ssl.h>
#include <string>
2014-01-16 15:35:39 +00:00
#ifndef KEEPINSYNCWMD
#define KEEPINSYNCWMD
enum acTKScenario {
ACTK_ALONE = 0,
ACTK_INSECURE,
ACTK_OTEA,
ACTK_OTEB,
ACTK_OTEC,
ACTK_PROD,
N_ACTK_SCENARIOS
};
#endif
class TLSSocket
{
public:
TLSSocket(SSL_CTX* ctx, int sock, const std::string& host,
int port, int soTimeout) throw (SSLException);
~TLSSocket();
const std::string& getCertificateCommonName() const
{
return commonName;
}
int writeInt(int i) throw (SSLException);
int readInt() throw (SSLException);
int writeBytes(const std::string& bytes) throw (SSLException);
void readFully(std::string& buffer, int length) throw (SSLException);
private:
TLSSocket(const TLSSocket&);
TLSSocket& operator=(const TLSSocket&);
std::string commonName;
SSL* ssl;
};
#endif // __TLS_SOCKET_HPP