我想在我的openresty代码中使用sha256,所以尝试安装lua-resty-string。
我显然遗漏了一些其他的包,但不知道是哪一个。lua-resty-string homepage没有提供我能看到的任何线索。
$ docker run --rm -it openresty/openresty bash
# apt-get update && apt-get install luarocks
# luarocks install lua-resty-string
Installing https://luarocks.org/lua-resty-string-0.09-0.rockspec
lua-resty-string 0.09-0 is now installed in /usr/local (license: )
root@28fe64c51c5a:/# luajit
LuaJIT 2.1.0-beta3 -- Copyright (C) 2005-2017 Mike Pall. http://luajit.org/
JIT: ON SSE2 SSE3 SSE4.1 fold cse dce fwd dse narrow loop abc sink fuse
> resty_sha256 = require "resty.sha256"
> sha256 = resty_sha256:new()
/usr/local/share/lua/5.1/resty/sha256.lua:41: luajit: undefined symbol: SHA256_Init
stack traceback:
[C]: in function '__index'
/usr/local/share/lua/5.1/resty/sha256.lua:41: in function 'new'
stdin:1: in main chunk
[C]: at 0x55cd1fdaf250如果luarocks能够正确地构建或安装软件,我会更加确信。
(这一次)我错过了什么?
发布于 2019-12-09 12:43:18
似乎只有当代码由nginx服务器执行时,lua-resty-string包才能工作。
root@62817b2fe1b2:/# ldd `which nginx`
linux-vdso.so.1 (0x00007ffe3b1db000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fa367a81000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fa367a60000)
libcrypt.so.1 => /lib/x86_64-linux-gnu/libcrypt.so.1 (0x00007fa367a26000)
libluajit-5.1.so.2 => /usr/local/openresty/luajit/lib/libluajit-5.1.so.2 (0x00007fa3679a3000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fa367820000)
libpcre.so.1 => /usr/local/openresty/pcre/lib/libpcre.so.1 (0x00007fa3677ad000)
libssl.so.1.1 => /usr/local/openresty/openssl/lib/libssl.so.1.1 (0x00007fa367739000)
libcrypto.so.1.1 => /usr/local/openresty/openssl/lib/libcrypto.so.1.1 (0x00007fa3674ad000)
libz.so.1 => /usr/local/openresty/zlib/lib/libz.so.1 (0x00007fa367490000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fa3672cf000)
/lib64/ld-linux-x86-64.so.2 (0x00007fa367c97000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fa3672b5000)
root@62817b2fe1b2:/# nm -D /usr/local/openresty/openssl/lib/libcrypto.so.1.1 | grep SHA256_Init
00000000001b12a0 T SHA256_Init而且这个库还附带了openresty:
root@62817b2fe1b2:/# dpkg -S /usr/local/openresty/openssl/lib/libcrypto.so.1.1
openresty-openssl: /usr/local/openresty/openssl/lib/libcrypto.so.1.1所以真正的问题,我想是,你如何告诉luajit加载这个库,以便它可以在导入resty.sha256时解析SHA256_Init。
这似乎可以用ffi来完成
local ffi = require("ffi")
local crypto = ffi.load("/usr/local/openresty/openssl/lib/libcrypto.so.1.1", true)https://stackoverflow.com/questions/59242386
复制相似问题