You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
I am using lua-resty-hmac as part of lua-resty-jwt but signature is always empty. It seems hmac is returning nil digest. but if I use resty.string sha1 algorithm, it works fine.
Below is my nginx/openresty version
/opt/openresty/bin/resty -V
resty 0.03
nginx version:nginx/1.9.3.1
built by clang 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
built with OpenSSL 0.9.8zd 8 Jan 2015
TLS SNI support enabled
configure arguments: --prefix=/opt/openresty/nginx --with-cc-opt='-O2 -I/usr/local/include' --add- module=../ngx_devel_kit-0.2.19 --add-module=../echo-nginx-module-0.58 --add-module=../xss-nginx- module-0.05 --add-module=../ngx_coolkit-0.2rc3 --add-module=../set-misc-nginx-module-0.29 --add- module=../form-input-nginx-module-0.11 --add-module=../encrypted-session-nginx-module-0.04 --add-module=../srcache-nginx-module-0.30 --add-module=../ngx_lua-0.9.16 --add-module=../ngx_lua_upstream-0.03 --add-module=../headers-more-nginx-module-0.26 --add-module=../array-var-nginx-module-0.04 --add-module=../memc-nginx-module-0.16 --add-module=../redis2-nginx-module-0.12 --add-module=../redis-nginx-module-0.3.7 --add-module=../rds-json-nginx-module-0.14 --add-module=../rds-csv-nginx-module-0.06 --with-ld-opt='-Wl,-rpath,/opt/openresty/luajit/lib -L/usr/local/lib' --with-http_ssl_module
resty.hmac
local hmac = require "resty.hmac"
local str = require "resty.string"
local hmac_sha1 = hmac:new("secret_key", hmac.ALGOS.SHA1)
if not hmac_sha1 then
ngx.say("failed to create the hmac_sha1 object")
return
end
local ok = hmac_sha1:update("hello ")
if not ok then
ngx.say("Failed to update str")
return
end
local digest = hmac_sha1:final("world",true)
ngx.say("hmac_sha1: ", digest)
resty.string sha1
local resty_sha1 = require "resty.sha1"
local str = require "resty.string"
local sha1 = resty_sha1:new()
if not sha1 then
ngx.say("failed to get sha1 object")
return
end
local ok = sha1:update("hello word")
if not ok then
ngx.say("Failed to update str")
return
end
local digest = sha1:final() -- binary digest
ngx.say("sha1: ", str.to_hex(digest))
The text was updated successfully, but these errors were encountered:
OpenSSL 1.x+ is a prerequisite for lua-resty-hmac. This is a common issue I've seen when developing on OSX (see the comments on this PR for help using a more recent version of OpenSSL on OSX).
Hello,
I am using lua-resty-hmac as part of lua-resty-jwt but signature is always empty. It seems hmac is returning nil digest. but if I use resty.string sha1 algorithm, it works fine.
Below is my nginx/openresty version
resty.hmac
resty.string sha1
The text was updated successfully, but these errors were encountered: