funtik::SSLConnection Class Reference
[A connection for an XML-RPC call]

The class for support ssl connections. More...

#include <ssl_connection.h>

Inheritance diagram for funtik::SSLConnection:

Inheritance graph
[legend]
Collaboration diagram for funtik::SSLConnection:

Collaboration graph
[legend]
List of all members.

Public Types

enum  AuthType { CA_AUTH = 1, FINGERPRINT_AUTH = 2, MANDATORY_CLIENTCERT = 4, CHECK_REVOCATIONCERT = 8 }

Public Member Functions

 SSLConnection (bool server, const ulxr::CppString &domain, unsigned port=80)
 Constructs a generic connection, primarily for a client.
 SSLConnection (bool server, long adr=INADDR_ANY, unsigned port=0)
 Constructs a generic connection, primarily for a server.
virtual ~SSLConnection ()
 Constructs a connection.
virtual void close ()
 Closes the connection.
virtual ulxr::Connectiondetach ()
 Detaches the connection by creating a duplicate of the connection and closing the original connection afterwards.
virtual void open ()
 Opens the connection in rpc client mode.
virtual void accept ()
 Opens the connection in rpc server mode, thus waiting for connections from clients.
virtual ulxr::CppString getInterfaceName ()
 Tests if the current transmission expects a return value.
virtual void cut ()
 Cuts the connection.
void setCryptographyData (const std::string &password, const std::string &certfile, const std::string &keyfile)
 Sets the cryptography data.
void setPassword (const std::string &strPassword)
 Set the password for cryptography client`s certificate.
std::string getPassword () const
 Get the password.
void setCertFile (const std::string &strCertFile)
 set the certificate.
std::string getCertFileName () const
 get name of certificate.
void setKeyFile (const std::string &strCertFileName)
std::string getKeyFileName () const
 get name of key.
void setCAFile (const std::string &strCAFile)
 Sets the CA file data.
void enableAuth (int iType)
 Enable SSL authentificate.
void disableAuth (int iType=0)
 Disable SSL authentificate.
void addFingerprintData (const std::string &strFingerprint)
 Adds the fingerprint of client`s certificate.
void resetFingerprintData ()
 Reset all fingerprint data of client`s certificate.
void addRevocationData (const std::string &strRevocation)
 Adds the fingerprint of revocation client`s certificate.
void resetRevocationData ()
 Reset all fingerprint data of revocation certificates.
bool checkFingerprint (std::string strFingerprint) const
 Check fingerprint in fingerprint data.
bool checkRevocationFingerprint (std::string strFingerprint) const
 Check fingerprint in revocation fingerprint data.
std::string calculateFingerprint (X509 *poCertificate) const
 Calculates certificate fingerprint.

Protected Member Functions

bool checkAccess (X509 *poCertificate)
 Check certificate in fingerprint data and revocation data.
void activateAuth ()
 activate security functions.
SSL * getSslObject () const
 Returns the SSL object.
SSL_CTX * getSslContextObject () const
 Returns the SSL context object.
SSL_SESSION * getSslSessionObject () const
 Returns the SSL session object.
virtual bool hasPendingInput () const
 Checks if there is input data which can immediately be read.
void createSSL ()
 Create SSL object.
void initializeCTX ()
 Initialise SSL context data.
virtual ssize_t low_level_write (char const *buff, long len)
 Actually writes data to the connection.
virtual ssize_t low_level_read (char *buff, long len)
 Reads data from the connection.
void init ()
 Initializes internal variables.

Protected Attributes

int m_iAuthType
 if m_CA_auth is true then used authentification by means of CA certificate.
std::string m_strCAFileName
std::map< std::string, int > m_mapFingerpintData
std::map< std::string, int > m_mapRevocationData
std::string m_strPassword
std::string m_strKeyFileName
std::string m_strCertFileName
SSL * ssl
SSL_CTX * ssl_ctx
SSL_SESSION * session

Static Protected Attributes

static bool ssl_initialized

Detailed Description

The class for support ssl connections.

This support SSL connections for server and client. This support SSL authentification,check certificates, etc.

Definition at line 88 of file ssl_connection.h.


Member Enumeration Documentation

enum funtik::SSLConnection::AuthType

Enumerator:
CA_AUTH 
FINGERPRINT_AUTH 
MANDATORY_CLIENTCERT 
CHECK_REVOCATIONCERT 

Definition at line 241 of file ssl_connection.h.


Constructor & Destructor Documentation

funtik::SSLConnection::SSLConnection ( bool  server,
const ulxr::CppString domain,
unsigned  port = 80 
)

Constructs a generic connection, primarily for a client.

The connection is not yet open after construction.

Parameters:
server true: bind socket to adress for server mode
domain domain name of the server
port port on the the server

Definition at line 180 of file ssl_connection.cpp.

References init(), ULXR_PCHAR, and ULXR_TRACE.

Referenced by detach().

funtik::SSLConnection::SSLConnection ( bool  server,
long  adr = INADDR_ANY,
unsigned  port = 0 
)

Constructs a generic connection, primarily for a server.

The connection is not yet open after construction.

Parameters:
server true: bind socket to adress for server mode
adr accepted client adress
port port on which the connect is accepted

Definition at line 188 of file ssl_connection.cpp.

References init(), ULXR_PCHAR, and ULXR_TRACE.

funtik::SSLConnection::~SSLConnection (  )  [virtual]

Constructs a connection.

The connection is not yet open after construction.

Definition at line 275 of file ssl_connection.cpp.

References close(), session, ssl_ctx, ULXR_PCHAR, and ULXR_TRACE.


Member Function Documentation

void funtik::SSLConnection::close (  )  [virtual]

Closes the connection.

Reimplemented from ulxr::TcpIpConnection.

Definition at line 293 of file ssl_connection.cpp.

References ulxr::TcpIpConnection::close(), ULXR_PCHAR, and ULXR_TRACE.

Referenced by ~SSLConnection().

ulxr::Connection * funtik::SSLConnection::detach (  )  [virtual]

Detaches the connection by creating a duplicate of the connection and closing the original connection afterwards.

Returns:
the current connection

Reimplemented from ulxr::TcpIpConnection.

Definition at line 374 of file ssl_connection.cpp.

References cut(), ulxr::TcpIpConnection::getServerData(), session, ulxr::TcpIpConnection::setServerData(), ssl, ssl_ctx, SSLConnection(), ULXR_PCHAR, and ULXR_TRACE.

void funtik::SSLConnection::open (  )  [virtual]

Opens the connection in rpc client mode.

Reimplemented from ulxr::TcpIpConnection.

Definition at line 420 of file ssl_connection.cpp.

References ulxr::TcpIpConnection::open(), ULXR_PCHAR, and ULXR_TRACE.

void funtik::SSLConnection::accept (  )  [virtual]

Opens the connection in rpc server mode, thus waiting for connections from clients.

Definition at line 461 of file ssl_connection.cpp.

References ulxr::TcpIpConnection::accept(), ULXR_GET_STRING, ULXR_PCHAR, and ULXR_TRACE.

ulxr::CppString funtik::SSLConnection::getInterfaceName (  )  [virtual]

Tests if the current transmission expects a return value.

Returns:
true: return value for request

Reimplemented from ulxr::TcpIpConnection.

Definition at line 494 of file ssl_connection.cpp.

References ULXR_PCHAR, and ULXR_TRACE.

void funtik::SSLConnection::cut (  )  [virtual]

Cuts the connection.

Just the variables are reset,creted new ssl_ctx, the connection itself is not touched.

Reimplemented from ulxr::Connection.

Definition at line 502 of file ssl_connection.cpp.

References ulxr::Connection::cut(), ULXR_PCHAR, and ULXR_TRACE.

Referenced by detach().

void funtik::SSLConnection::setCryptographyData ( const std::string &  password,
const std::string &  certfile,
const std::string &  keyfile 
)

Sets the cryptography data.

Parameters:
password password for the crypto files
certfile name of the servers or clients certificate file (PEM format)
keyfile name of the servers or clients private key file (PEM format)

Definition at line 197 of file ssl_connection.cpp.

References ULXR_GET_STRING, ulxr_i18n, and ULXR_PCHAR.

void funtik::SSLConnection::setPassword ( const std::string &  strPassword  ) 

Set the password for cryptography client`s certificate.

Parameters:
strPassword password for the crypto files.

Definition at line 533 of file ssl_connection.cpp.

std::string funtik::SSLConnection::getPassword (  )  const

Get the password.

Returns the password for key.

Returns:
password

Definition at line 510 of file ssl_connection.cpp.

Referenced by funtik::password_cb().

void funtik::SSLConnection::setCertFile ( const std::string &  strCertFile  ) 

set the certificate.

Set the name of the servers or clients certificate file (PEM format). Function will be generate exception if certificate have bad format.

Parameters:
strCertFile name of the certificate file

Definition at line 538 of file ssl_connection.cpp.

References ULXR_GET_STRING, ulxr_i18n, and ULXR_PCHAR.

std::string funtik::SSLConnection::getCertFileName (  )  const

get name of certificate.

Get the name of the servers or clients certificate file.

Returns:
name of the certificate file.

Definition at line 559 of file ssl_connection.cpp.

void funtik::SSLConnection::setKeyFile ( const std::string &  strCertFileName  ) 

Definition at line 547 of file ssl_connection.cpp.

References ULXR_GET_STRING, ulxr_i18n, and ULXR_PCHAR.

std::string funtik::SSLConnection::getKeyFileName (  )  const

get name of key.

Get the name of the servers or clients key file.

Returns:
name of the key file.

Definition at line 554 of file ssl_connection.cpp.

void funtik::SSLConnection::setCAFile ( const std::string &  strCAFile  ) 

Sets the CA file data.

Parameters:
strCAFile name of file contains client`s certificates

Definition at line 587 of file ssl_connection.cpp.

References ULXR_GET_STRING, ulxr_i18n, and ULXR_PCHAR.

void funtik::SSLConnection::enableAuth ( int  iType  ) 

Enable SSL authentificate.

Enable SSL authentificate. Maybe two types of authentificate. CA_AUTH all signed certificates is validate(need call function for set CA file). FINGERPRINT_AUTH certificate is validate if server or client has one fingerprint.

Note: if need

Parameters:
iType type of authentificate.
See also:

Definition at line 580 of file ssl_connection.cpp.

void funtik::SSLConnection::disableAuth ( int  iType = 0  ) 

Disable SSL authentificate.

Disable SSL authentificate options.

Parameters:
iType type of disabled authentificate. if iType is 0 or absent all authentificate set disable.

Definition at line 566 of file ssl_connection.cpp.

void funtik::SSLConnection::addFingerprintData ( const std::string &  strFingerprint  ) 

Adds the fingerprint of client`s certificate.

For Generating fingerpint for certificate certificate.pem use next command: openssl x509 -fingerprint -in ./certificate.pem

Parameters:
strFingerprint filename with fingerprints.

Definition at line 614 of file ssl_connection.cpp.

void funtik::SSLConnection::resetFingerprintData (  ) 

Reset all fingerprint data of client`s certificate.

Definition at line 624 of file ssl_connection.cpp.

void funtik::SSLConnection::addRevocationData ( const std::string &  strRevocation  ) 

Adds the fingerprint of revocation client`s certificate.

Parameters:
strRevocation filename with revocation fingerprints.

Definition at line 619 of file ssl_connection.cpp.

void funtik::SSLConnection::resetRevocationData (  ) 

Reset all fingerprint data of revocation certificates.

Definition at line 629 of file ssl_connection.cpp.

bool funtik::SSLConnection::checkFingerprint ( std::string  strFingerprint  )  const

Check fingerprint in fingerprint data.

Parameters:
strFingerprint 
Returns:
true if fingerprint of certificate present, else false.

Definition at line 660 of file ssl_connection.cpp.

bool funtik::SSLConnection::checkRevocationFingerprint ( std::string  strFingerprint  )  const

Check fingerprint in revocation fingerprint data.

Parameters:
strFingerprint 
Returns:
true if fingerprint of certificate present, else false.

Definition at line 670 of file ssl_connection.cpp.

std::string funtik::SSLConnection::calculateFingerprint ( X509 *  poCertificate  )  const

Calculates certificate fingerprint.

Returns:
fingerprint of certificate.

Definition at line 635 of file ssl_connection.cpp.

bool funtik::SSLConnection::checkAccess ( X509 *  poCertificate  )  [protected]

Check certificate in fingerprint data and revocation data.

This is used by accept and open functions.

Returns:
true if access allow, else false.

Definition at line 678 of file ssl_connection.cpp.

References CHECK_REVOCATIONCERT, and FINGERPRINT_AUTH.

void funtik::SSLConnection::activateAuth (  )  [protected]

activate security functions.

Active security. Used in enableAuth and disableAuth functions.

Definition at line 714 of file ssl_connection.cpp.

SSL * funtik::SSLConnection::getSslObject (  )  const [protected]

Returns the SSL object.

Returns:
pointer to ssl object

Definition at line 516 of file ssl_connection.cpp.

SSL_CTX * funtik::SSLConnection::getSslContextObject (  )  const [protected]

Returns the SSL context object.

Returns:
pointer to ssl context object

Definition at line 522 of file ssl_connection.cpp.

SSL_SESSION * funtik::SSLConnection::getSslSessionObject (  )  const [protected]

Returns the SSL session object.

Returns:
pointer to ssl session object

Definition at line 528 of file ssl_connection.cpp.

bool funtik::SSLConnection::hasPendingInput (  )  const [protected, virtual]

Checks if there is input data which can immediately be read.

Returns:
true: data available

Reimplemented from ulxr::Connection.

Definition at line 341 of file ssl_connection.cpp.

References ULXR_PCHAR, and ULXR_TRACE.

void funtik::SSLConnection::createSSL (  )  [protected]

Create SSL object.

Definition at line 394 of file ssl_connection.cpp.

References funtik::s_server_auth_session_id_context, ulxr_i18n, ULXR_PCHAR, and ULXR_TRACE.

void funtik::SSLConnection::initializeCTX (  )  [protected]

Initialise SSL context data.

!!

Definition at line 222 of file ssl_connection.cpp.

References funtik::password_cb(), funtik::s_server_session_id_context, ulxr_i18n, ULXR_PCHAR, and ULXR_TRACE.

ssize_t funtik::SSLConnection::low_level_write ( char const *  buff,
long  len 
) [protected, virtual]

Actually writes data to the connection.

Parameters:
buff pointer to data
len valid buffer length
Returns:
result from api write function

Reimplemented from ulxr::Connection.

Definition at line 318 of file ssl_connection.cpp.

References ULXR_PCHAR, and ULXR_TRACE.

ssize_t funtik::SSLConnection::low_level_read ( char *  buff,
long  len 
) [protected, virtual]

Reads data from the connection.

Parameters:
buff pointer to data buffer
len maimum number of bytes to read into buffer
Returns:
result from api read function

Reimplemented from ulxr::Connection.

Definition at line 352 of file ssl_connection.cpp.

References ULXR_PCHAR, and ULXR_TRACE.

void funtik::SSLConnection::init (  )  [protected]

Initializes internal variables.

Reimplemented from ulxr::Connection.

Definition at line 258 of file ssl_connection.cpp.

References ULXR_PCHAR, and ULXR_TRACE.

Referenced by SSLConnection().


Member Data Documentation

int funtik::SSLConnection::m_iAuthType [protected]

if m_CA_auth is true then used authentification by means of CA certificate.

Path to the CA certificates must be in variable m_CA_file.

Definition at line 304 of file ssl_connection.h.

std::string funtik::SSLConnection::m_strCAFileName [protected]

Definition at line 305 of file ssl_connection.h.

std::map<std::string,int> funtik::SSLConnection::m_mapFingerpintData [protected]

Definition at line 307 of file ssl_connection.h.

std::map<std::string,int> funtik::SSLConnection::m_mapRevocationData [protected]

Definition at line 308 of file ssl_connection.h.

std::string funtik::SSLConnection::m_strPassword [protected]

Definition at line 310 of file ssl_connection.h.

std::string funtik::SSLConnection::m_strKeyFileName [protected]

Definition at line 311 of file ssl_connection.h.

std::string funtik::SSLConnection::m_strCertFileName [protected]

Definition at line 312 of file ssl_connection.h.

SSL* funtik::SSLConnection::ssl [protected]

Definition at line 360 of file ssl_connection.h.

Referenced by detach().

SSL_CTX* funtik::SSLConnection::ssl_ctx [protected]

Definition at line 361 of file ssl_connection.h.

Referenced by detach(), and ~SSLConnection().

SSL_SESSION* funtik::SSLConnection::session [protected]

Definition at line 362 of file ssl_connection.h.

Referenced by detach(), and ~SSLConnection().

bool funtik::SSLConnection::ssl_initialized [static, protected]

Definition at line 364 of file ssl_connection.h.


The documentation for this class was generated from the following files:
Generated on Sun Aug 19 20:09:01 2007 for ulxmlrpcpp by  doxygen 1.5.1