Skip to content

Dependency on luaossl troublingΒ #802

Closed

Description

@a-schaefers

Hi Leafo πŸ‘‹ πŸ˜„

So I just can't get this lib to build on arch linux for the life of me. I was able to get it going on macos, though [ツ)_/Β―

Please just close this if I'm the problem or if this is a dupe. But in my research tonight, I believe I am not the only one.

Currently as I see it, https://github.com/wahern/luaossl appears unmaintained, 13 pull requests open, no updates in 3 years, and better options may be out there?

wahern/luaossl#220

Here this guy tried Lua both 5.3, 5.4, OpenSSL 3.5 and I tried Luajit with Both 3.5 and 1.1.

I did manage to get it to build with luajit, but only after jumping through quite a few hoops, so I was surprised to test my app on linux and run in to trouble - usually other way around. If it matters, here is how I got it working on mac:

export LUA_VERSION=5.1
export LUA_DIR=/opt/homebrew/opt/openresty/luajit
export PATH="$LUA_DIR/bin:$HOME/bin:$PATH"
export LAPIS_OPENRESTY="/opt/homebrew/bin/openresty"
export CRYPTO_DIR="/opt/homebrew/opt/openssl@3"
export CRYPTO_LIBDIR="$CRYPTO_DIR/lib"
export CRYPTO_INCDIR="$CRYPTO_DIR/include"
export PKG_CONFIG_PATH="/opt/homebrew/opt/openssl@3/lib/pkgconfig"

# with lua symlinked to luajit and front of my PATH
# + with luarocks compiled from source in the above environment and again put on path front

# finally I can cd to lapis and do this:
eval "$(luarocks --lua-version=5.1 --tree=lua_modules path)
luarocks make --only-deps --tree=lua_modules $PROJECT-0.1-1.rockspec \
  CRYPTO_INCDIR=/opt/homebrew/opt/openssl@3/include \
  CRYPTO_LIBDIR=/opt/homebrew/opt/openssl@3/lib \
  OPENSSL_INCDIR=/opt/homebrew/opt/openssl@3/include \
  OPENSSL_LIBDIR=/opt/homebrew/opt/openssl@3/lib

# with lapis listed in my dependencies among other things, it builds

The luaossl issue tracker is choke full of people struggling to build.

I don't mean to be a downer, i love lapis so much and have had SO MUCH FUN building things with it, and I hate web dev.

A quick search, I found https://github.com/zhaozg/lua-openssl and https://github.com/lunarmodules/luasec and I'm also wondering how much lift it would be to make the switch to one of these? I don't mean to create a bunch of work, but maybe it needs to be done? If it's already on the map, again sorry.

Trying to figure out how to save other people some time. This already sunk my night. πŸ˜† If there's a straight forward path to buildling lapis without ssl deps ...

(I already tried a couple hacks, couldn't get it to go after purging luaossl and some modules I think were depending on it, it ended up going back to utf8 stuff I think and I gave up, decided the better path might be to just switch ssl libs in the lapis codebase...),

...i'd be open to that too, because i think we could just fall back to using libcurl or something?

Cheers 🍻

Related issues in lapis open status: #632 #766 #783
and closed: #799 #698 #688 #667 #612 #595 #576 #560 #545 #539

Activity

  1. jprjr commented on Jun 30, 2025

    @jprjr

    Hi there - just wanted to mention, I believe I've found the ultimate cause of the compile error and a workaround:

    CC="gcc -std=gnu99" luarocks install luaossl
    

    You could probably also use -std=c99 in place of -std=gnu99 - I'm not sure if gnu99 is really needed. The main point is to force GCC 15+ to not use C23. Once the rock is installed you should be able to install lapis normally.

    I have details in some comments on luaossl#220

  2. a-schaefers commented on Oct 8, 2026

    @a-schaefers
    Author

    the report was accurate when it was filed, and upstream has since fixed most of it. GCC 15+ compiles C23 by default, and luaossl 20220711 didn't build under C23. I reproduced the exact errors from luaossl#220. luaossl fixed its side in 20250929. OpenSSL fixed a second culprit in its ocsp.h header in 3.0.19, 3.4.4, 3.5.5, 3.6.1 and 4.0. On an Arch-equivalent toolchain (C23 with OpenSSL 3.6.5), luarocks install lapis now succeeds.

    What still holds:

    • With GCC 15+ and an OpenSSL older than those releases, even the latest luaossl fails to build.
    • Lapis loads luaossl when its modules load (lapis/util/encoding.moon:5, lapis/csrf.moon:4), so every app needs it, even on OpenResty where ngx.hmac_sha1 does the signing.
    • The replacements the issue suggests don't fit. Lapis only uses luaossl for HMAC and random bytes, not TLS.
  3. a-schaefers commented on Oct 12, 2026

    @a-schaefers
    Author

    From here, when wahern/luaossl#222 is merged upstream, this impacts in the following ways:

    • What src/openssl.c: avoid PEM_write_bio_OCSP_RESPONSE() to fix C23 buildsΒ wahern/luaossl#222 fixes: with it, luaossl builds under GCC 15’s default C23 against any OpenSSL. Before, it failed with any OpenSSL that still had the old cast: Ubuntu 25.10’s 3.5.3, and all of 1.1.1, 3.1 and 3.2. The earlier C23 breakage was already fixed in luaossl 20250929.

    • It only reaches users after a release. luarocks install lapis pulls the published luaossl rock, so nothing changes for users until wahern merges #222 and publishes a new release. Until then, the docs workaround in leafo/lapis#821 (CFLAGS="-std=gnu17") is what helps.

  4. a-schaefers commented on Oct 13, 2026

    @a-schaefers
    Author

    #821 closed, This PR wasoverkill, things are being fixed upstream in wahern/luaossl#222 this and will flow naturally resolved in to lapis. CFLAGS="-O2 -fPIC -std=gnu17" can help people hitting the edge case during this inbetween time and it being documented here in the github issue is enough.

  5. a-schaefers commented on Oct 13, 2026

    @a-schaefers
    Author

    So once #222 is released, #820 also isn’t needed for #802. It only has value as a step toward leafo dropping the hard dependency, which nobody has asked for. Thus closing.

  6. a-schaefers commented on Oct 13, 2026

    @a-schaefers
    Author

    With the merging of wahern/luaossl#222

    AND

    documentation of

    CFLAGS="-O2 -fPIC -std=gnu17"

    and

    CC="gcc -std=gnu99" luarocks install luaossl

    workarounds discussed here in this issue thread,

    this entire issue can be closed. Cheers 🍻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions