Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

which lua-resty-hmac lua script to use? #3

Open
bcherukuri opened this issue May 24, 2018 · 1 comment · May be fixed by #4
Open

which lua-resty-hmac lua script to use? #3

bcherukuri opened this issue May 24, 2018 · 1 comment · May be fixed by #4

Comments

@bcherukuri
Copy link

I tried to use https://github.com/jkeys089/lua-resty-hmac but it is not working!

Getting following error

2018/05/24 17:45:17 [error] 7#7: *1 lua entry thread aborted: runtime error: /usr/local/openresty/nginx/conf/lua/resty/hmac.lua:124: attempt to get length of local 'key' (a nil value)
stack traceback:
coroutine 0:
/usr/local/openresty/nginx/conf/lua/resty/hmac.lua: in function 'new'
/usr/local/openresty/nginx/conf/lua/resty/aws_auth.lua:55: in function 'get_derived_signing_key'
/usr/local/openresty/nginx/conf/lua/resty/aws_auth.lua:106: in function 'get_authorization'
/usr/local/openresty/nginx/conf/lua/resty/aws_auth.lua:136: in function 'aws_set_headers'
/usr/local/openresty/nginx/conf/lua/resty/aws_auth.lua:147: in function 's3_set_headers'
access_by_lua(nginx.conf:124):1: in function <access_by_lua(nginx.conf:124):1> while sending to client, client: 172.30.60.26, server: , request: "GET xxx HTTP/1.1", host: "172.30.60.26"

@bcherukuri
Copy link
Author

I believe this is due to the wrong hmac lua approach

lua-resty-aws is calling:

local h = resty_hmac:new()
Where as lua-resty-hmac is expecting


function _M.new(self, key, hash_algo)
    local ctx = ctx_new()

    local _hash_algo = hash_algo or hashes.md5

    if C.HMAC_Init_ex(ctx, key, #key, _hash_algo, nil) == 0 then
        return nil
    end

    ffi_gc(ctx, ctx_free)

    return setmetatable({ _ctx = ctx }, mt)
end

@edgesite edgesite linked a pull request Jun 6, 2019 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant