Changeset 4288
- Timestamp:
- 03/04/09 14:09:32 (4 years ago)
- Location:
- luci/trunk/libs/nixio
- Files:
-
- 1 removed
- 1 modified
-
axTLS/.prepared (deleted)
-
src/tls-context.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
luci/trunk/libs/nixio/src/tls-context.c
r4275 r4288 44 44 const char *method = luaL_optlstring(L, 1, "tlsv1", NULL); 45 45 46 luaL_getmetatable(L, NIXIO_TLS_CTX_META); 46 47 SSL_CTX **ctx = lua_newuserdata(L, sizeof(SSL_CTX *)); 47 48 if (!ctx) { … … 50 51 51 52 /* create userdata */ 52 lua L_getmetatable(L, NIXIO_TLS_CTX_META);53 lua_pushvalue(L, -2); 53 54 lua_setmetatable(L, -2); 55 lua_getfield(L, -1, "tls_defaultkey"); 54 56 55 57 if (!strcmp(method, "tlsv1")) { … … 61 63 } 62 64 63 64 SSL_CTX_set_options(*ctx, SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3);65 66 65 if (!(*ctx)) { 67 66 return luaL_error(L, "unable to create TLS context"); 68 67 } 68 69 const char *autoload = lua_tostring(L, -1); 70 if (autoload) { 71 SSL_CTX_use_PrivateKey_file(*ctx, autoload, SSL_FILETYPE_PEM); 72 } 73 lua_pop(L, 1); 74 75 SSL_CTX_set_options(*ctx, SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3); 69 76 70 77 return 1; … … 203 210 luaL_register(L, NULL, R); 204 211 212 #ifndef WITH_AXTLS 213 lua_pushliteral(L, "openssl"); 214 #else 215 lua_pushliteral(L, "axtls"); 216 #endif 217 lua_setfield(L, -2, "tls_provider"); 218 205 219 /* create context metatable */ 206 220 luaL_newmetatable(L, NIXIO_TLS_CTX_META); … … 208 222 lua_setfield(L, -2, "__index"); 209 223 luaL_register(L, NULL, CTX_M); 210 lua_pop(L, 1); 211 } 224 #ifdef WITH_AXTLS 225 lua_pushliteral(L, "/etc/private.rsa"); 226 lua_setfield(L, -2, "tls_defaultkey"); 227 #endif 228 lua_setfield(L, -2, "meta_tls_context"); 229 }
