DEV: sslkeylogger: handle file opening error
Prevent a Lua error if output file cannot be opened when logging SSL keys. Report a warning instead with the error description.
This commit is contained in:
parent
b019636cd7
commit
e1e6fbb3fd
|
@ -28,14 +28,18 @@ local function sslkeylog(txn, filename)
|
||||||
|
|
||||||
-- ensure that a key is written only once by using a session variable
|
-- ensure that a key is written only once by using a session variable
|
||||||
if not txn:get_var('sess.sslkeylogdone') then
|
if not txn:get_var('sess.sslkeylogdone') then
|
||||||
file = io.open(filename, 'a')
|
local file, err = io.open(filename, 'a')
|
||||||
for fieldname, fetch in pairs(fields) do
|
if file then
|
||||||
if fetch() then
|
for fieldname, fetch in pairs(fields) do
|
||||||
file:write(string.format('%s %s %s\n', fieldname, client_random, fetch()))
|
if fetch() then
|
||||||
|
file:write(string.format('%s %s %s\n', fieldname, client_random, fetch()))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
file:close()
|
||||||
|
else
|
||||||
|
core.Warning("Cannot open SSL log file: " .. err .. ".")
|
||||||
end
|
end
|
||||||
|
|
||||||
file:close()
|
|
||||||
txn:set_var('sess.sslkeylogdone', true)
|
txn:set_var('sess.sslkeylogdone', true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue