src/x509.c

changeset 25
4bc25168aa1c
parent 24
bbf12f9be71c
child 26
bbff42d46512
equal deleted inserted replaced
24:bbf12f9be71c 25:4bc25168aa1c
256 to_hex((char*)buffer, bytes, hex_buffer); 256 to_hex((char*)buffer, bytes, hex_buffer);
257 lua_pushlstring(L, hex_buffer, bytes*2); 257 lua_pushlstring(L, hex_buffer, bytes*2);
258 return 1; 258 return 1;
259 } 259 }
260 260
261 int meth_destroy(lua_State* L)
262 {
263 X509_free(luasec_to_x509(L, 1));
264 return 0;
265 }
266
261 /** 267 /**
262 * Certificate metamethods 268 * Certificate metamethods
263 */ 269 */
264 static luaL_Reg meta[] = { 270 static luaL_Reg meta[] = {
265 {"subject", meth_subject}, 271 {"subject", meth_subject},
276 /* Register the functions and tables */ 282 /* Register the functions and tables */
277 luaL_newmetatable(L, "SSL:Certificate"); 283 luaL_newmetatable(L, "SSL:Certificate");
278 lua_newtable(L); 284 lua_newtable(L);
279 luaL_register(L, NULL, meta); 285 luaL_register(L, NULL, meta);
280 lua_setfield(L, -2, "__index"); 286 lua_setfield(L, -2, "__index");
281 287 lua_pushcfunction(L, meth_destroy);
288 lua_setfield(L, -2, "__gc");
282 lua_newtable(L); 289 lua_newtable(L);
283 return 1; 290 return 1;
284 } 291 }

mercurial