![]() |
SSLInitializer Class Reference#include <SSLInitializer.h>
Collaboration diagram for SSLInitializer:
![]()
Detailed DescriptionDefinition at line 52 of file SSLInitializer.h. Constructor & Destructor Documentation
init openssl bio_err create random file
Definition at line 62 of file SSLInitializer.cpp. References bio_err, DEB, Utility::GetEnv(), m_rand_file, m_rand_size, Utility::SetEnv(), SSL_id_function(), and SSL_locking_function(). 00063 { 00064 DEB( fprintf(stderr, "SSLInitializer()\n");) 00065 00066 bio_err = NULL; 00067 m_rand_size = 1024; 00068 00069 /* An error write context */ 00070 bio_err = BIO_new_fp(stderr, BIO_NOCLOSE); 00071 00072 /* Global system initialization*/ 00073 SSL_library_init(); 00074 SSL_load_error_strings(); 00075 OpenSSL_add_all_algorithms(); 00076 CRYPTO_set_locking_callback( SSL_locking_function ); 00077 CRYPTO_set_id_callback( SSL_id_function ); 00078 00079 std::string randfile = Utility::GetEnv("RANDFILE"); 00080 std::string home = Utility::GetEnv("HOME"); 00081 if (randfile.empty() && home.empty()) 00082 { 00083 std::string homepath = Utility::GetEnv("HOMEPATH"); 00084 if (!homepath.empty()) 00085 { 00086 Utility::SetEnv("HOME", homepath); 00087 } 00088 } 00089 char path[512]; 00090 *path = 0; 00091 RAND_file_name(path, 512); 00092 if (*path) 00093 { 00094 m_rand_file = path; 00095 m_rand_size = 1024; 00096 RAND_write_file(path); 00097 } 00098 else 00099 { 00100 DEB( fprintf(stderr, "SSLInitializer: no random file generated\n");) 00101 } 00102 00103 /* Load randomness */ 00104 if (!m_rand_file.size() || !RAND_load_file(m_rand_file.c_str(), m_rand_size)) 00105 { 00106 DEB( fprintf(stderr, "SSLInitializer: PRNG not initialized\n");) 00107 } 00108 00109 }
remove random file
Definition at line 112 of file SSLInitializer.cpp. References DEB, and DeleteRandFile(). 00113 { 00114 DEB( fprintf(stderr, "~SSLInitializer()\n");) 00115 DeleteRandFile(); 00116 // %! delete mutexes 00117 }
Member Function Documentation
Definition at line 120 of file SSLInitializer.cpp. References m_rand_file. Referenced by ~SSLInitializer(). 00121 { 00122 if (m_rand_file.size()) 00123 { 00124 #ifdef _WIN32 00125 _unlink(m_rand_file.c_str()); 00126 #else 00127 unlink(m_rand_file.c_str()); 00128 #endif 00129 } 00130 }
SSL; mutex locking function callback.
Definition at line 133 of file SSLInitializer.cpp. References MMap(), and MMapMutex(). Referenced by SSLInitializer(). 00134 { 00135 IMutex *mutex = NULL; 00136 { 00137 Lock lock(MMapMutex()); 00138 if (MMap().find(n) == MMap().end()) 00139 { 00140 MMap()[n] = new Mutex; 00141 } 00142 mutex = MMap()[n]; 00143 } 00144 if (mode & CRYPTO_LOCK) 00145 { 00146 mutex -> Lock(); 00147 } 00148 else 00149 { 00150 mutex -> Unlock(); 00151 } 00152 }
Return thread id.
Definition at line 155 of file SSLInitializer.cpp. References Utility::ThreadID(). Referenced by SSLInitializer(). 00156 { 00157 return Utility::ThreadID(); 00158 }
Definition at line 161 of file SSLInitializer.cpp. References m_mmap. Referenced by SSL_locking_function(). 00162 { 00163 if (m_mmap == NULL) 00164 m_mmap = new std::map<int, IMutex *>(); 00165 return *m_mmap; 00166 }
Definition at line 169 of file SSLInitializer.cpp. References m_mmap_mutex. Referenced by SSL_locking_function(). 00170 { 00171 if (m_mmap_mutex == NULL) 00172 m_mmap_mutex = new Mutex(); 00173 return *m_mmap_mutex; 00174 }
Member Data Documentation
Definition at line 78 of file SSLInitializer.h. Referenced by DeleteRandFile(), and SSLInitializer().
The documentation for this class was generated from the following files: |