lm_ssl.c
changeset 59 19cfaceda6bb
parent 57 37ed3c7ac1b6
child 62 d92358eafead
equal deleted inserted replaced
58:24998d36f3e4 59:19cfaceda6bb
     1 
     1 
     2 /* Copyright 2009 Myhailo Danylenko
     2 /* Copyright 2009-2016 Myhailo Danylenko
     3 
     3 
     4 This file is part of lua-lm.
     4 This file is part of lua-lm.
     5 
     5 
     6 lua-lm is free software: you can redistribute it and/or modify
     6 lua-lm is free software: you can redistribute it and/or modify
     7 it under the terms of the GNU General Public License as published by
     7 it under the terms of the GNU General Public License as published by
   164 	} else {
   164 	} else {
   165 		lua_pushnil (L);
   165 		lua_pushnil (L);
   166 	}
   166 	}
   167 	return 1;
   167 	return 1;
   168 }
   168 }
       
   169 
       
   170 #ifdef HAVE_LM_SSL_SET_CA
       
   171 /// ssl:ca_path
       
   172 /// Set path to trusted ssl certificates. Argument must be a name of a PEM file
       
   173 /// or a name of directory with hashed certificates.
       
   174 /// A: string (path)
       
   175 static int ca_path_lm_ssl (lua_State *L)
       
   176 {
       
   177 	llm_ssl_t *object = luaL_checklm_ssl (L, 1);
       
   178 	const gchar *path = luaL_checkstring (L, 2);
       
   179 	lm_ssl_set_ca (object -> ssl, path);
       
   180 	return 0;
       
   181 }
       
   182 #endif
       
   183 
       
   184 #ifdef HAVE_LM_SSL_SET_CIPHER_LIST
       
   185 /// ssl:cipher_list
       
   186 /// Set list of allowed ciphers (colon-separated). Names may vary depending on ssl
       
   187 /// implementation in use.
       
   188 /// A: string (cipher list)
       
   189 static int cipher_list_lm_ssl (lua_State *L)
       
   190 {
       
   191 	llm_ssl_t *object = luaL_checklm_ssl (L, 1);
       
   192 	const gchar *list = luaL_checkstring (L, 2);
       
   193 	lm_ssl_set_cipher_list (object -> ssl, list);
       
   194 	return 0;
       
   195 }
       
   196 #endif
   169 
   197 
   170 /// ssl:fingerprint
   198 /// ssl:fingerprint
   171 /// Returns fingerprint of remote server.
   199 /// Returns fingerprint of remote server.
   172 /// R: string or nil
   200 /// R: string or nil
   173 static int fingerprint_lm_ssl (lua_State *L)
   201 static int fingerprint_lm_ssl (lua_State *L)
   238 	{ "supported", supported_lm_ssl },
   266 	{ "supported", supported_lm_ssl },
   239 	{ NULL,        NULL             },
   267 	{ NULL,        NULL             },
   240 };
   268 };
   241 
   269 
   242 const static luaL_Reg reg_m_lm_ssl[] = {
   270 const static luaL_Reg reg_m_lm_ssl[] = {
       
   271 #ifdef HAVE_LM_SSL_SET_CA
       
   272 	{ "ca_path",     ca_path_lm_ssl     },
       
   273 #endif
       
   274 #ifdef HAVE_LM_SSL_SET_CIPHER_LIST
       
   275 	{ "cipher_list", cipher_list_lm_ssl },
       
   276 #endif
   243 	{ "fingerprint", fingerprint_lm_ssl },
   277 	{ "fingerprint", fingerprint_lm_ssl },
   244 	{ "tls",         tls_lm_ssl         },
   278 	{ "tls",         tls_lm_ssl         },
   245 	{ "pointer",     pointer_lm_ssl     },
   279 	{ "pointer",     pointer_lm_ssl     },
   246 	{ "__gc",        gc_lm_ssl          },
   280 	{ "__gc",        gc_lm_ssl          },
   247 	{ NULL,          NULL               },
   281 	{ NULL,          NULL               },