crystal-lang / crystal

The Crystal Programming Language
https://crystal-lang.org
Apache License 2.0
19.47k stars 1.62k forks source link

Support for libreSSL 3.5 #12647

Closed straight-shoota closed 3 months ago

straight-shoota commented 2 years ago

I have a branch that adds specs for testing the SSL bindings against libreSSL: https://github.com/crystal-lang/crystal/compare/master...straight-shoota:crystal:feature/ci-alpine-libressl-3.5

Lots of specs are failing (https://github.com/straight-shoota/crystal/actions/runs/3303496182/jobs/5451483965). Mostly with this error:

SSL_connect: error:20FFF078:BIO routines:CRYPTO_internal:uninitialized (OpenSSL::SSL::Error)

I have not found any details about this error message. But it looks like we might be missing some initialization.

LibreSSL 3.5 is the version provided in Alpine Linux 3.16 which our alpine docker images are based on. Using libreSSL in these images currently fails (by default, Alpine Linux uses OpenSSL, though; you'd need to switch to libreSSL explicitly).

gnojus commented 1 year ago

I did some digging around, and this is due to an extra field in a struct by libressl: https://github.com/libressl/openbsd/blob/9338f2e503bcf0185656636d62eec3005ed27254/src/lib/libcrypto/bio/bio_local.h#L79 Which is not reflected by the crystals definition in https://github.com/crystal-lang/crystal/blob/4ea385a2d3d67b14776ac8cd5cfb9b2d68f172b6/src/openssl/lib_crypto.cr#L56 and thus not set as initialized because all the offsets are wrong.

The current implementation seems hacky and prone to future regressions -- is it really necessary to have own definitions by crystal? Is the provided, exported ssl interface not enough?

TheWanderer1983 commented 3 months ago

I'm getting this exact same issue when building invidious on OpenBSD 7.5. It's using crystal. Is there any solution yet? It builds successfully on FreeBSD so I assume they aren't using libreSSL.