GENERIC_SERVER  0.0.0.9
A light-weight, cross-platform, pluggable, extensible and secure framework for deploying C++ plug-ins.
 All Classes Files Functions Variables Typedefs Pages
Public Member Functions | Private Attributes | List of all members
SSLServer Class Reference

Utility class for TLS. Please refer excellent documentation at: http://www.openssl.org/docs/ssl/ssl.html. More...

#include <sslserver.h>

Public Member Functions

 SSLServer ()
 Constructors.
 
 SSLServer (char *cFile, char *kFile)
 
int set_priv_key (string priv_key)
 
int set_ca_cert (string ca_cert)
 
int set_cert_file (string server_cert_file)
 
int set_verify_client (bool status_flag)
 
int CreateCTX (void)
 Load algorithms and create context.
 
int LoadCerts (void)
 Load certification files.
 
SSL_CTX * get_ctx (void)
 
int tls_init (void)
 
int tls_cleanup (void)
 

Private Attributes

SSL_CTX * ctx
 
string cert_file
 
string priv_key_file
 
string ca_certificate
 
bool verify_client
 

Detailed Description

Utility class for TLS. Please refer excellent documentation at: http://www.openssl.org/docs/ssl/ssl.html.

Definition at line 50 of file sslserver.h.

Member Function Documentation

int SSLServer::tls_init ( void  )

Initialize TLS. Setup CRYPTO locking callbacks,RNG,mutuxes.

Definition at line 74 of file sslserver.cpp.

75 {
76  int i;
77 
78  SSL_load_error_strings();
79  SSL_library_init();
80  // Load algorithms and error strings.
81  OpenSSL_add_all_algorithms();
82  /* static locks area */
83 #ifdef WINDOWS
84  mutex_buf = (HANDLE *) malloc(CRYPTO_num_locks() * sizeof(HANDLE));
85 #else
86  mutex_buf = (pthread_mutex_t *) malloc(CRYPTO_num_locks() * sizeof(pthread_mutex_t));
87 #endif
88  if (mutex_buf == NULL)
89  return (0);
90  for (i = 0; i < CRYPTO_num_locks(); i++)
91  {
92 #ifdef WINDOWS
93  mutex_buf[i] = CreateMutex( NULL, FALSE, NULL );
94 #else
95  pthread_mutex_init(&mutex_buf[i], NULL);
96 #endif
97  }
98  /* static locks callbacks */
99  CRYPTO_set_locking_callback(locking_function);
100  CRYPTO_set_id_callback(id_function);
101  /* dynamic locks callbacks */
102  CRYPTO_set_dynlock_create_callback(dyn_create_function);
103  CRYPTO_set_dynlock_lock_callback(dyn_lock_function);
104  CRYPTO_set_dynlock_destroy_callback(dyn_destroy_function);
105 #ifndef WINDOWS
106  RAND_load_file("/dev/urandom", 1024);
107 // OpenSSL uses several sources of entropy automatically on Windows
108 #endif
109  return (1);
110 }

The documentation for this class was generated from the following files: