swift-kafka-client icon indicating copy to clipboard operation
swift-kafka-client copied to clipboard

Undeclared function 'RAND_priv_bytes' after switch to BoringSSL

Open axelandersson opened this issue 1 year ago • 6 comments

$ sw_vers 
ProductName:            macOS
ProductVersion:         14.0
BuildVersion:           23A344
$ swift -v
Apple Swift version 5.9 (swiftlang-5.9.0.128.108 clang-1500.0.40.1)

Checked out main:

commit 5dbf2fadd2ae30d4a90a1df0b8a02083727ba36a (HEAD -> main, origin/main, origin/HEAD)
Author: Felix Schlegel <[email protected]>
Date:   Thu Oct 5 10:16:41 2023 +0200

    Ship with BoringSSL (#135)

Pulled librdkafka:

$ git submodule update --remote
Cloning into '/Users/axel/swift-kafka-client/Sources/Crdkafka/librdkafka'...
Submodule path 'Sources/Crdkafka/librdkafka': checked out 'be353be5f6ceaa11a95e21472e981d871ab1aaee'

Ran swift test:

/Users/axel/swift-kafka-client/Sources/Crdkafka/librdkafka/src/rdkafka_admin.c:5481:21: error: call to undeclared function 'RAND_priv_bytes'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
                if (RAND_priv_bytes(random_salt, sizeof(random_salt)) == 1) {

axelandersson avatar Oct 09 '23 12:10 axelandersson

Thanks for reporting this. @axelandersson what OS are you trying to build this library on?

FranzBusch avatar Oct 09 '23 13:10 FranzBusch

Thanks for reporting this. @axelandersson what OS are you trying to build this library on?

This is on Sonoma 14.0 with Xcode 15 toolchain. Swift version:

Apple Swift version 5.9 (swiftlang-5.9.0.128.108 clang-1500.0.40.1)

axelandersson avatar Oct 09 '23 13:10 axelandersson

Ah you updated the librdkafka version. If you don't do git submodule update --remote then it should build fine. @felixschlegel we gotta check why it fails on the latest librdkafka version though.

FranzBusch avatar Oct 09 '23 13:10 FranzBusch

@FranzBusch anything we can do to help out here?

hassila avatar Nov 22 '23 14:11 hassila

@FranzBusch anything we can do to help out here?

Would appreciate a PR for it. I think the solution should be as easy as doing something like this #define RAND_priv_bytes(x,sz) RAND_bytes((x),(sz)) in a C file where we shim boringssl to openssl.

FranzBusch avatar Nov 22 '23 14:11 FranzBusch

https://github.com/swift-server/swift-kafka-client/pull/148

:-)

hassila avatar Nov 22 '23 17:11 hassila