lua-resty-aws icon indicating copy to clipboard operation
lua-resty-aws copied to clipboard

which lua-resty-hmac lua script to use?

Open bcherukuri opened this issue 7 years ago • 1 comments

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 avatar May 24 '18 18:05 bcherukuri

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

bcherukuri avatar May 24 '18 18:05 bcherukuri