lm_ssl.c
changeset 59 19cfaceda6bb
parent 57 37ed3c7ac1b6
child 62 d92358eafead
--- a/lm_ssl.c	Sat Mar 05 14:57:58 2016 +0200
+++ b/lm_ssl.c	Sat Mar 05 15:43:04 2016 +0200
@@ -1,5 +1,5 @@
 
-/* Copyright 2009 Myhailo Danylenko
+/* Copyright 2009-2016 Myhailo Danylenko
 
 This file is part of lua-lm.
 
@@ -167,6 +167,34 @@
 	return 1;
 }
 
+#ifdef HAVE_LM_SSL_SET_CA
+/// ssl:ca_path
+/// Set path to trusted ssl certificates. Argument must be a name of a PEM file
+/// or a name of directory with hashed certificates.
+/// A: string (path)
+static int ca_path_lm_ssl (lua_State *L)
+{
+	llm_ssl_t *object = luaL_checklm_ssl (L, 1);
+	const gchar *path = luaL_checkstring (L, 2);
+	lm_ssl_set_ca (object -> ssl, path);
+	return 0;
+}
+#endif
+
+#ifdef HAVE_LM_SSL_SET_CIPHER_LIST
+/// ssl:cipher_list
+/// Set list of allowed ciphers (colon-separated). Names may vary depending on ssl
+/// implementation in use.
+/// A: string (cipher list)
+static int cipher_list_lm_ssl (lua_State *L)
+{
+	llm_ssl_t *object = luaL_checklm_ssl (L, 1);
+	const gchar *list = luaL_checkstring (L, 2);
+	lm_ssl_set_cipher_list (object -> ssl, list);
+	return 0;
+}
+#endif
+
 /// ssl:fingerprint
 /// Returns fingerprint of remote server.
 /// R: string or nil
@@ -240,6 +268,12 @@
 };
 
 const static luaL_Reg reg_m_lm_ssl[] = {
+#ifdef HAVE_LM_SSL_SET_CA
+	{ "ca_path",     ca_path_lm_ssl     },
+#endif
+#ifdef HAVE_LM_SSL_SET_CIPHER_LIST
+	{ "cipher_list", cipher_list_lm_ssl },
+#endif
 	{ "fingerprint", fingerprint_lm_ssl },
 	{ "tls",         tls_lm_ssl         },
 	{ "pointer",     pointer_lm_ssl     },