Changeset 505
- Timestamp:
- 08/15/07 10:03:32 (1 year ago)
- Files:
-
- version_0/ext/ssl.cpp (modified) (4 diffs)
- version_0/ext/ssl.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
version_0/ext/ssl.cpp
r325 r505 121 121 **************************/ 122 122 123 SslContext_t::SslContext_t (bool is_server ):123 SslContext_t::SslContext_t (bool is_server, const string &privkeyfile, const string &certchainfile): 124 124 pCtx (NULL), 125 125 PrivateKey (NULL), 126 126 Certificate (NULL) 127 127 { 128 /* TODO: the usage of the specified private-key and cert-chain filenames only applies to 129 * client-side connections at this point. Server connections currently use the default materials. 130 * That needs to be fixed asap. 131 * Also, in this implementation, server-side connections use statically defined X-509 defaults. 132 * One thing I'm really not clear on is whether or not you have to explicitly free X509 and EVP_PKEY 133 * objects when we call our destructor, or whether just calling SSL_CTX_free is enough. 134 */ 135 128 136 if (!bLibraryInitialized) { 129 137 bLibraryInitialized = true; … … 160 168 SSL_CTX_set_session_id_context (pCtx, (unsigned char*)"eventmachine", 12); 161 169 } 162 163 } 170 else { 171 int e; 172 if (privkeyfile.length() > 0) { 173 e = SSL_CTX_use_PrivateKey_file (pCtx, privkeyfile.c_str(), SSL_FILETYPE_PEM); 174 assert (e > 0); 175 } 176 if (certchainfile.length() > 0) { 177 e = SSL_CTX_use_certificate_chain_file (pCtx, certchainfile.c_str()); 178 assert (e > 0); 179 } 180 } 181 } 182 183 164 184 165 185 /*************************** … … 183 203 ******************/ 184 204 185 SslBox_t::SslBox_t (bool is_server ):205 SslBox_t::SslBox_t (bool is_server, const string &privkeyfile, const string &certchainfile): 186 206 bIsServer (is_server), 187 207 pSSL (NULL), … … 189 209 pbioWrite (NULL) 190 210 { 191 Context = new SslContext_t (bIsServer); 211 /* TODO someday: make it possible to re-use SSL contexts so we don't have to create 212 * a new one every time we come here. 213 */ 214 215 Context = new SslContext_t (bIsServer, privkeyfile, certchainfile); 192 216 assert (Context); 193 217 version_0/ext/ssl.h
r325 r505 34 34 { 35 35 public: 36 SslContext_t (bool is_server );36 SslContext_t (bool is_server, const string &privkeyfile, const string &certchainfile); 37 37 virtual ~SslContext_t(); 38 38 … … 58 58 { 59 59 public: 60 SslBox_t (bool is_server );60 SslBox_t (bool is_server, const string &privkeyfile, const string &certchainfile); 61 61 virtual ~SslBox_t(); 62 62
