aboutsummaryrefslogtreecommitdiffstats
path: root/src/openssl.ssl.context.lua
blob: 54cbad77d0787caf87497bc0858b4207e832f2cf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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, ...)
		ciphers = table.concat(ciphers_t, ":", 1, ciphers_t.n)
	elseif type(ciphers) == "table" then
		ciphers = table.concat(ciphers, ":")
	end
	return setCipherList(self, ciphers)
end)

-- Allow passing a vararg of curves, or an array
local setCurvesList = ctx.interpose("setCurvesList", nil)
if setCurvesList then
	ctx.interpose("setCurvesList", function (self, curves, ...)
		if (...) then
			local curves_t = pack(curves, ...)
			curves = table.concat(curves_t, ":", 1, curves_t.n)
		elseif type(curves) == "table" then
			curves = table.concat(curves, ":")
		end
		return setCurvesList(self, curves)
	end)
end

-- Allow passing a vararg of ciphersuites, or an array
local setCipherSuites = ctx.interpose("setCipherSuites", nil)
if setCipherSuites then
	ctx.interpose("setCipherSuites", function (self, ciphers, ...)
		if (...) then
			local ciphers_t = pack(ciphers, ...)
			ciphers = table.concat(ciphers_t, ":", 1, ciphers_t.n)
		elseif type(ciphers) == "table" then
			ciphers = table.concat(ciphers, ":")
		end
		return setCipherSuites(self, ciphers)
	end)
end

return ctx