Hi Taylor,
I've successfully built nginx + lua-nginx-module + LuaJIT-dependencies entirely statically and it's not hard to do.
The problem is that the ffi references to the compiled functions are run-time not compile-time. As a result of this, the linker finds no references to the function and just leaves it out of the final binary (reducing it's size). The solution to this is to bracket the archive with the `-Wl,--whole-archive` and `-Wl,--no-whole-archive` options. (In your case something like `--with-ld-opt="/usr/local/lib/
resty_cjose.o -Wl,-E -Wl,--whole-archive /usr/local/lib/libcjose.a -Wl,--no-whole-archive"`). This forces the linker to include the entire archive into the final binary without removing any of its functions.
I really hope that helps you.
On Thursday, July 6, 2017 at 11:03:41 PM UTC+9:30, Taylor King wrote:
Thanks for the response. I tried lua-resty-jwt but had trouble getting it to take the key in JWK format. If I convert the jwk to pem and hook into openssl calling openssl rsa -inform pem -in key.pem -pubout -RSAPublicKey_in, lt will validate it correctly, but I haven't been able to find lua code to convert a JWK into pem, and I'd add a dependency on openssl. I've tried linking in cjose by setting the flag --with-ld-opt="/usr/local/lib/
resty_cjose.o -Wl,-E /usr/local/lib/libcjose.a" Openresty compiles correctly but if I run nm on the binary, the cjose functions I'm calling from FFI aren't in there. If possible i'd like to statically link in both the lua code and cjose at openresty compile time
On Thursday, July 6, 2017 at 4:27:20 AM UTC-4, Aapo Talvensaari wrote:On Wed, 5 Jul 2017 at 23.58 Taylor King <
tkin...@gmail.com> wrote:
Is it possible to link a C library into openresty at compile time and call it from FFI? Here is a pull request for our openwhisk apigateway I am working on:
https://github.com/apache/incubator-openwhisk-apigateway/pull/237/files.. I need to be able to link in cjose, and would like to have an elegant way to call it from lua code. As it stands right now, I have to compile cjose seperately and put it on LD_LIBRARY_PATH. I wrote this lua module to wrap it nicely in lua
https://github.com/taylorking/lua-resty-cjose. I know it's possible to statically link lua code compiled with luajit, if I can't statically link C code is there a cleaner way to do this? If anybody knows how to perform JWS validation with a JWK in openresty it would save me from having to do this altogether.
It should be possible. Have you tried? There is also lua-resty-jwt and I have built my own using lua-resty-nettle (my Nettle based lib is not published, though).