From b34f9c0fd6a815f498c03717384ba8dd543e75f7 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Sun, 9 Aug 2015 00:47:35 +1000 Subject: Allow passing openssl.ssl.context:setCipherList a vararg of ciphers, or an array --- src/openssl.ssl.context.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/openssl.ssl.context.lua b/src/openssl.ssl.context.lua index 44a9163..2da84de 100644 --- a/src/openssl.ssl.context.lua +++ b/src/openssl.ssl.context.lua @@ -1,3 +1,16 @@ local ctx = require"_openssl.ssl.context" +local pack = table.pack or function(...) return { n = select("#", ...); ... } end + +-- Allow passing a vararg of ciphers, or an array +local setCipherList; setCipherList = ctx.interpose("setCipherList", function (self, ciphers, ...) + if (...) then + local ciphers_t = pack(...) + ciphers = table.concat(ciphers_t, ":", 1, ciphers_t.n) + elseif type(ciphers) == "table" then + ciphers = table.concat(ciphers, ":") + end + return setCipherList(self, ciphers) +end) + return ctx -- cgit v1.2.3-55-g6feb From 18cb0387fd063f1b2874c44dab11bbc319cc86ca Mon Sep 17 00:00:00 2001 From: daurnimator Date: Sun, 9 Aug 2015 00:54:45 +1000 Subject: documentation: Update to say that setCipherList can take multiple arguments --- doc/luaossl.tex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/luaossl.tex b/doc/luaossl.tex index de461ba..433dd03 100644 --- a/doc/luaossl.tex +++ b/doc/luaossl.tex @@ -871,9 +871,9 @@ Sets the X.509 certificate \module{openssl.x509} object $crt$ to send during SSL Sets the private key \module{openssl.pkey} object $key$ for use during SSL connection instance handshakes. -\subsubsection[\fn{context:setCipherList}]{\fn{context:setCipherList($string$)}} +\subsubsection[\fn{context:setCipherList}]{\fn{context:setCipherList($string$ [, ...])}} -Sets the allowed public key and private key algorithms. The string format is documented in the \href{http://www.openssl.org/docs/apps/ciphers.html#CIPHER_LIST_FORMAT}{OpenSSL ciphers(1) utility documentation}. +Sets the allowed public key and private key algorithm(s). The string format is documented in the \href{http://www.openssl.org/docs/apps/ciphers.html#CIPHER_LIST_FORMAT}{OpenSSL ciphers(1) utility documentation}. \subsubsection[\fn{context:setEphemeralKey}]{\fn{context:setEphemeralKey($key$)}} -- cgit v1.2.3-55-g6feb From c80559d64791e42f8fec9056343f4629720323e4 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Sun, 15 Nov 2015 20:31:47 +1100 Subject: Fix not passing through first cipher argument in vararg form --- src/openssl.ssl.context.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/openssl.ssl.context.lua b/src/openssl.ssl.context.lua index 2da84de..2098b54 100644 --- a/src/openssl.ssl.context.lua +++ b/src/openssl.ssl.context.lua @@ -5,7 +5,7 @@ local pack = table.pack or function(...) return { n = select("#", ...); ... } en -- Allow passing a vararg of ciphers, or an array local setCipherList; setCipherList = ctx.interpose("setCipherList", function (self, ciphers, ...) if (...) then - local ciphers_t = pack(...) + local ciphers_t = pack(ciphers, ...) ciphers = table.concat(ciphers_t, ":", 1, ciphers_t.n) elseif type(ciphers) == "table" then ciphers = table.concat(ciphers, ":") -- cgit v1.2.3-55-g6feb