Skip to content

Commit

Permalink
fix(openssl) correctly check error for getting version num (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
nasrullo authored Jun 25, 2020
1 parent 5cbc247 commit 6a4b9e6
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/resty/openssl/version.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ end)

if not ok then
-- 1.0.x
local _
_, version_num = pcall(function()
ok, version_num = pcall(function()
local num = C.SSLeay()
version_func = C.SSLeay_version
types_table = {
Expand All @@ -54,8 +53,13 @@ if not ok then
end)
end

if not version_num or version_num < 0x10000000 then
error(string.format("OpenSSL version %x is not supported", version_num or 0))

if not ok then
error(string.format("OpenSSL has encountered an error: %s", tostring(version_num)))
elseif type(version_num) == 'number' and version_num < 0x10000000 then
error(string.format("OpenSSL version %s is not supported", tostring(version_num or 0)))
elseif not version_num then
error("Can not get OpenSSL version")
end

if version_num >= 0x30000000 then
Expand Down

0 comments on commit 6a4b9e6

Please sign in to comment.