karafka-rdkafka 0.20.0.rc5-arm64-darwin → 0.21.0-arm64-darwin
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/{ci_linux_x86_64_musl.yml → ci_linux_alpine_x86_64_musl.yml} +63 -71
- data/.github/workflows/ci_linux_alpine_x86_64_musl_complementary.yml +264 -0
- data/.github/workflows/ci_linux_debian_x86_64_gnu.yml +271 -0
- data/.github/workflows/ci_linux_debian_x86_64_gnu_complementary.yml +334 -0
- data/.github/workflows/{ci_linux_x86_64_gnu.yml → ci_linux_ubuntu_aarch64_gnu.yml} +78 -56
- data/.github/workflows/ci_linux_ubuntu_aarch64_gnu_complementary.yml +295 -0
- data/.github/workflows/ci_linux_ubuntu_x86_64_gnu.yml +281 -0
- data/.github/workflows/ci_linux_ubuntu_x86_64_gnu_complementary.yml +294 -0
- data/.github/workflows/ci_macos_arm64.yml +28 -50
- data/.github/workflows/push_linux_aarch64_gnu.yml +65 -0
- data/.github/workflows/push_linux_x86_64_gnu.yml +4 -3
- data/.github/workflows/push_linux_x86_64_musl.yml +6 -4
- data/.github/workflows/push_macos_arm64.yml +3 -3
- data/.github/workflows/push_ruby.yml +1 -1
- data/.github/workflows/trigger-wiki-refresh.yml +30 -0
- data/.github/workflows/verify-action-pins.yml +1 -1
- data/.gitignore +1 -0
- data/.rspec +1 -0
- data/.ruby-version +1 -1
- data/CHANGELOG.md +18 -2
- data/README.md +48 -147
- data/dist/cyrus-sasl-2.1.28.tar.gz +0 -0
- data/dist/krb5-1.21.3.tar.gz +0 -0
- data/dist/openssl-3.0.16.tar.gz +0 -0
- data/dist/zlib-1.3.1.tar.gz +0 -0
- data/dist/zstd-1.5.7.tar.gz +0 -0
- data/docker-compose-ssl.yml +35 -0
- data/ext/build_common.sh +18 -3
- data/ext/build_linux_aarch64_gnu.sh +326 -0
- data/ext/build_linux_x86_64_gnu.sh +17 -6
- data/ext/build_linux_x86_64_musl.sh +18 -8
- data/ext/build_macos_arm64.sh +7 -0
- data/ext/generate-ssl-certs.sh +109 -0
- data/ext/librdkafka.dylib +0 -0
- data/karafka-rdkafka.gemspec +3 -1
- data/lib/rdkafka/bindings.rb +6 -8
- data/lib/rdkafka/config.rb +1 -4
- data/lib/rdkafka/consumer.rb +1 -1
- data/lib/rdkafka/producer.rb +11 -6
- data/lib/rdkafka/version.rb +3 -3
- data/spec/integrations/ssl_stress_spec.rb +121 -0
- data/spec/{rdkafka → lib/rdkafka}/admin_spec.rb +219 -6
- data/spec/{rdkafka → lib/rdkafka}/bindings_spec.rb +0 -24
- data/spec/{rdkafka → lib/rdkafka}/config_spec.rb +1 -1
- data/spec/{rdkafka → lib/rdkafka}/consumer_spec.rb +50 -6
- data/spec/{rdkafka → lib/rdkafka}/metadata_spec.rb +2 -2
- data/spec/{rdkafka → lib/rdkafka}/producer/delivery_report_spec.rb +1 -1
- data/spec/{rdkafka → lib/rdkafka}/producer_spec.rb +301 -8
- data/spec/spec_helper.rb +65 -16
- metadata +87 -43
- data/spec/rdkafka/producer/partitions_count_spec.rb +0 -359
- /data/spec/{rdkafka → lib/rdkafka}/abstract_handle_spec.rb +0 -0
- /data/spec/{rdkafka → lib/rdkafka}/admin/create_acl_handle_spec.rb +0 -0
- /data/spec/{rdkafka → lib/rdkafka}/admin/create_acl_report_spec.rb +0 -0
- /data/spec/{rdkafka → lib/rdkafka}/admin/create_topic_handle_spec.rb +0 -0
- /data/spec/{rdkafka → lib/rdkafka}/admin/create_topic_report_spec.rb +0 -0
- /data/spec/{rdkafka → lib/rdkafka}/admin/delete_acl_handle_spec.rb +0 -0
- /data/spec/{rdkafka → lib/rdkafka}/admin/delete_acl_report_spec.rb +0 -0
- /data/spec/{rdkafka → lib/rdkafka}/admin/delete_topic_handle_spec.rb +0 -0
- /data/spec/{rdkafka → lib/rdkafka}/admin/delete_topic_report_spec.rb +0 -0
- /data/spec/{rdkafka → lib/rdkafka}/admin/describe_acl_handle_spec.rb +0 -0
- /data/spec/{rdkafka → lib/rdkafka}/admin/describe_acl_report_spec.rb +0 -0
- /data/spec/{rdkafka → lib/rdkafka}/callbacks_spec.rb +0 -0
- /data/spec/{rdkafka → lib/rdkafka}/consumer/headers_spec.rb +0 -0
- /data/spec/{rdkafka → lib/rdkafka}/consumer/message_spec.rb +0 -0
- /data/spec/{rdkafka → lib/rdkafka}/consumer/partition_spec.rb +0 -0
- /data/spec/{rdkafka → lib/rdkafka}/consumer/topic_partition_list_spec.rb +0 -0
- /data/spec/{rdkafka → lib/rdkafka}/error_spec.rb +0 -0
- /data/spec/{rdkafka → lib/rdkafka}/native_kafka_spec.rb +0 -0
- /data/spec/{rdkafka → lib/rdkafka}/producer/delivery_handle_spec.rb +0 -0
- /data/spec/{rdkafka → lib/rdkafka}/producer/partitions_count_cache_spec.rb +0 -0
@@ -0,0 +1,35 @@
|
|
1
|
+
services:
|
2
|
+
kafka:
|
3
|
+
container_name: kafka
|
4
|
+
image: confluentinc/cp-kafka:8.0.0
|
5
|
+
ports:
|
6
|
+
- 9092:9092 # Support PLAINTEXT so we can run one docker setup for SSL and PLAINTEXT
|
7
|
+
- 9093:9093
|
8
|
+
volumes:
|
9
|
+
- ./ssl:/etc/kafka/secrets
|
10
|
+
environment:
|
11
|
+
CLUSTER_ID: kafka-docker-cluster-1
|
12
|
+
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
|
13
|
+
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
|
14
|
+
KAFKA_PROCESS_ROLES: broker,controller
|
15
|
+
KAFKA_CONTROLLER_LISTENER_NAMES: CONTROLLER
|
16
|
+
KAFKA_LISTENERS: PLAINTEXT://:9092,SSL://:9093,CONTROLLER://:9094
|
17
|
+
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT,SSL:SSL
|
18
|
+
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://127.0.0.1:9092,SSL://127.0.0.1:9093
|
19
|
+
KAFKA_BROKER_ID: 1
|
20
|
+
KAFKA_CONTROLLER_QUORUM_VOTERS: 1@127.0.0.1:9094
|
21
|
+
ALLOW_PLAINTEXT_LISTENER: 'yes'
|
22
|
+
KAFKA_AUTO_CREATE_TOPICS_ENABLE: 'true'
|
23
|
+
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
|
24
|
+
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
|
25
|
+
KAFKA_ALLOW_EVERYONE_IF_NO_ACL_FOUND: "true"
|
26
|
+
KAFKA_AUTHORIZER_CLASS_NAME: org.apache.kafka.metadata.authorizer.StandardAuthorizer
|
27
|
+
|
28
|
+
# SSL Configuration
|
29
|
+
KAFKA_SSL_KEYSTORE_FILENAME: kafka.server.keystore.jks
|
30
|
+
KAFKA_SSL_KEYSTORE_CREDENTIALS: kafka_keystore_creds
|
31
|
+
KAFKA_SSL_KEY_CREDENTIALS: kafka_ssl_key_creds
|
32
|
+
KAFKA_SSL_TRUSTSTORE_FILENAME: kafka.server.truststore.jks
|
33
|
+
KAFKA_SSL_TRUSTSTORE_CREDENTIALS: kafka_truststore_creds
|
34
|
+
KAFKA_SSL_CLIENT_AUTH: none
|
35
|
+
KAFKA_SSL_ENDPOINT_IDENTIFICATION_ALGORITHM: ""
|
data/ext/build_common.sh
CHANGED
@@ -19,7 +19,7 @@ readonly CYRUS_SASL_VERSION="2.1.28"
|
|
19
19
|
readonly ZLIB_VERSION="1.3.1"
|
20
20
|
readonly ZSTD_VERSION="1.5.7"
|
21
21
|
readonly KRB5_VERSION="1.21.3"
|
22
|
-
readonly LIBRDKAFKA_VERSION="2.
|
22
|
+
readonly LIBRDKAFKA_VERSION="2.11.0"
|
23
23
|
|
24
24
|
# SHA256 checksums for supply chain security
|
25
25
|
# Update these when upgrading versions
|
@@ -29,7 +29,7 @@ declare -A CHECKSUMS=(
|
|
29
29
|
["zlib-1.3.1.tar.gz"]="9a93b2b7dfdac77ceba5a558a580e74667dd6fede4585b91eefb60f03b72df23"
|
30
30
|
["zstd-${ZSTD_VERSION}.tar.gz"]="eb33e51f49a15e023950cd7825ca74a4a2b43db8354825ac24fc1b7ee09e6fa3"
|
31
31
|
["krb5-${KRB5_VERSION}.tar.gz"]="b7a4cd5ead67fb08b980b21abd150ff7217e85ea320c9ed0c6dadd304840ad35"
|
32
|
-
["librdkafka-${LIBRDKAFKA_VERSION}.tar.gz"]="
|
32
|
+
["librdkafka-${LIBRDKAFKA_VERSION}.tar.gz"]="592a823dc7c09ad4ded1bc8f700da6d4e0c88ffaf267815c6f25e7450b9395ca"
|
33
33
|
)
|
34
34
|
|
35
35
|
# Colors for output
|
@@ -94,12 +94,25 @@ secure_download() {
|
|
94
94
|
local url="$1"
|
95
95
|
local filename="$2"
|
96
96
|
|
97
|
+
# Check if file already exists in current directory (may have been already downloaded)
|
97
98
|
if [ -f "$filename" ]; then
|
98
99
|
log "File $filename already exists, verifying checksum..."
|
99
100
|
verify_checksum "$filename"
|
100
101
|
return 0
|
101
102
|
fi
|
102
103
|
|
104
|
+
# Check dist directory relative to script location
|
105
|
+
local script_dir
|
106
|
+
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
107
|
+
local dist_file="$script_dir/../dist/$filename"
|
108
|
+
|
109
|
+
if [ -f "$dist_file" ]; then
|
110
|
+
log "Using distributed $filename from dist/"
|
111
|
+
cp "$dist_file" "$filename"
|
112
|
+
verify_checksum "$filename"
|
113
|
+
return 0
|
114
|
+
fi
|
115
|
+
|
103
116
|
log "Downloading $filename from $url..."
|
104
117
|
|
105
118
|
# Use platform-appropriate download command
|
@@ -344,7 +357,9 @@ get_zstd_url() {
|
|
344
357
|
}
|
345
358
|
|
346
359
|
get_krb5_url() {
|
347
|
-
|
360
|
+
# Using MIT mirror since kerberos.org is down
|
361
|
+
# echo "https://kerberos.org/dist/krb5/${KRB5_VERSION%.*}/krb5-${KRB5_VERSION}.tar.gz"
|
362
|
+
echo "https://web.mit.edu/kerberos/dist/krb5/${KRB5_VERSION%.*}/krb5-${KRB5_VERSION}.tar.gz"
|
348
363
|
}
|
349
364
|
|
350
365
|
# Export functions and variables that scripts will need
|
@@ -0,0 +1,326 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
#
|
3
|
+
# Build self-contained librdkafka.so for Linux aarch64 GNU with checksum verification
|
4
|
+
# Usage: ./build_linux_aarch64_gnu.sh
|
5
|
+
#
|
6
|
+
# Expected directory structure:
|
7
|
+
# ext/build_linux_aarch64_gnu.sh (this script)
|
8
|
+
# ext/build_common.sh (shared functions)
|
9
|
+
# dist/librdkafka-*.tar.gz (librdkafka source tarball)
|
10
|
+
# dist/patches/*.patch (optional Ruby-specific patches)
|
11
|
+
#
|
12
|
+
set -euo pipefail
|
13
|
+
|
14
|
+
# Source common functions and constants
|
15
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
16
|
+
source "$SCRIPT_DIR/build_common.sh"
|
17
|
+
|
18
|
+
# Platform-specific paths
|
19
|
+
DIST_DIR="$SCRIPT_DIR/../dist"
|
20
|
+
PATCHES_DIR="$DIST_DIR/patches"
|
21
|
+
BUILD_DIR="$(pwd)/build-tmp"
|
22
|
+
DEPS_PREFIX="/tmp"
|
23
|
+
|
24
|
+
# Check common dependencies
|
25
|
+
check_common_dependencies
|
26
|
+
|
27
|
+
# Linux-specific dependency check
|
28
|
+
log "Checking Linux aarch64 GNU-specific build dependencies..."
|
29
|
+
command -v gcc &> /dev/null || error "gcc not found. Install with: apt-get install build-essential"
|
30
|
+
|
31
|
+
# Verify we're on ARM64 or cross-compiling
|
32
|
+
ARCH=$(uname -m)
|
33
|
+
if [[ "$ARCH" != "aarch64" && "$ARCH" != "arm64" ]]; then
|
34
|
+
warn "Not running on aarch64 ($ARCH detected). Ensure you have aarch64 cross-compilation tools if needed."
|
35
|
+
fi
|
36
|
+
|
37
|
+
# Auto-detect librdkafka tarball
|
38
|
+
log "Looking for librdkafka tarball in $DIST_DIR..."
|
39
|
+
LIBRDKAFKA_TARBALL=$(find_librdkafka_tarball "$DIST_DIR")
|
40
|
+
log "Found librdkafka tarball: $LIBRDKAFKA_TARBALL"
|
41
|
+
|
42
|
+
# Verify librdkafka tarball checksum if available
|
43
|
+
verify_librdkafka_checksum "$LIBRDKAFKA_TARBALL"
|
44
|
+
|
45
|
+
# Find patches
|
46
|
+
PATCHES_FOUND=()
|
47
|
+
find_patches "$PATCHES_DIR" PATCHES_FOUND
|
48
|
+
|
49
|
+
security_log "Starting secure build with checksum verification enabled"
|
50
|
+
log "Building self-contained librdkafka.so for Linux aarch64 GNU"
|
51
|
+
log "Dependencies to build:"
|
52
|
+
log " - OpenSSL: $OPENSSL_VERSION"
|
53
|
+
log " - Cyrus SASL: $CYRUS_SASL_VERSION"
|
54
|
+
log " - MIT Kerberos: $KRB5_VERSION"
|
55
|
+
log " - zlib: $ZLIB_VERSION"
|
56
|
+
log " - ZStd: $ZSTD_VERSION"
|
57
|
+
log "librdkafka source: $LIBRDKAFKA_TARBALL"
|
58
|
+
log "Build directory: $BUILD_DIR"
|
59
|
+
|
60
|
+
# Create build directory
|
61
|
+
mkdir -p "$BUILD_DIR"
|
62
|
+
cd "$BUILD_DIR"
|
63
|
+
|
64
|
+
# Build OpenSSL
|
65
|
+
log "Building OpenSSL $OPENSSL_VERSION for ARM64..."
|
66
|
+
OPENSSL_PREFIX="$DEPS_PREFIX/static-openssl-$OPENSSL_VERSION-arm64"
|
67
|
+
OPENSSL_TARBALL="openssl-$OPENSSL_VERSION.tar.gz"
|
68
|
+
OPENSSL_DIR="openssl-$OPENSSL_VERSION"
|
69
|
+
|
70
|
+
secure_download "$(get_openssl_url)" "$OPENSSL_TARBALL"
|
71
|
+
extract_if_needed "$OPENSSL_TARBALL" "$OPENSSL_DIR"
|
72
|
+
cd "$OPENSSL_DIR"
|
73
|
+
|
74
|
+
# Check if OpenSSL lib directory exists (lib or lib64)
|
75
|
+
if [ ! -f "$OPENSSL_PREFIX/lib/libssl.a" ] && [ ! -f "$OPENSSL_PREFIX/lib64/libssl.a" ]; then
|
76
|
+
log "Configuring and building OpenSSL for ARM64..."
|
77
|
+
export CFLAGS="-fPIC"
|
78
|
+
# Use linux-aarch64 target for ARM64
|
79
|
+
./Configure linux-aarch64 \
|
80
|
+
no-shared \
|
81
|
+
no-dso \
|
82
|
+
--prefix="$OPENSSL_PREFIX"
|
83
|
+
make clean || true
|
84
|
+
make -j$(get_cpu_count)
|
85
|
+
make install
|
86
|
+
unset CFLAGS
|
87
|
+
log "OpenSSL built successfully"
|
88
|
+
else
|
89
|
+
log "OpenSSL already built, skipping..."
|
90
|
+
fi
|
91
|
+
|
92
|
+
# Determine OpenSSL lib directory
|
93
|
+
if [ -f "$OPENSSL_PREFIX/lib64/libssl.a" ]; then
|
94
|
+
OPENSSL_LIB_DIR="$OPENSSL_PREFIX/lib64"
|
95
|
+
else
|
96
|
+
OPENSSL_LIB_DIR="$OPENSSL_PREFIX/lib"
|
97
|
+
fi
|
98
|
+
log "OpenSSL libraries in: $OPENSSL_LIB_DIR"
|
99
|
+
|
100
|
+
cd "$BUILD_DIR"
|
101
|
+
|
102
|
+
# Build MIT Kerberos (krb5)
|
103
|
+
log "Building MIT Kerberos $KRB5_VERSION for ARM64..."
|
104
|
+
KRB5_PREFIX="$DEPS_PREFIX/static-krb5-$KRB5_VERSION-arm64"
|
105
|
+
KRB5_TARBALL="krb5-$KRB5_VERSION.tar.gz"
|
106
|
+
KRB5_DIR="krb5-$KRB5_VERSION"
|
107
|
+
|
108
|
+
secure_download "$(get_krb5_url)" "$KRB5_TARBALL"
|
109
|
+
extract_if_needed "$KRB5_TARBALL" "$KRB5_DIR"
|
110
|
+
cd "$KRB5_DIR/src"
|
111
|
+
|
112
|
+
if [ ! -f "$KRB5_PREFIX/lib/libgssapi_krb5.a" ]; then
|
113
|
+
log "Configuring and building MIT Kerberos for ARM64..."
|
114
|
+
make clean 2>/dev/null || true
|
115
|
+
./configure --disable-shared --enable-static --prefix="$KRB5_PREFIX" \
|
116
|
+
--without-ldap --without-tcl --without-keyutils \
|
117
|
+
--disable-rpath --without-system-verto \
|
118
|
+
CFLAGS="-fPIC" CXXFLAGS="-fPIC"
|
119
|
+
|
120
|
+
# Build everything except the problematic kadmin tools
|
121
|
+
log "Building Kerberos (will ignore kadmin build failures)..."
|
122
|
+
make -j$(get_cpu_count) || {
|
123
|
+
log "Full build failed (expected due to kadmin), continuing with libraries..."
|
124
|
+
# The libraries should be built even if kadmin fails
|
125
|
+
true
|
126
|
+
}
|
127
|
+
|
128
|
+
# Install what was successfully built
|
129
|
+
make install || {
|
130
|
+
log "Full install failed, installing individual components..."
|
131
|
+
# Try to install the core libraries manually
|
132
|
+
make install-mkdirs 2>/dev/null || true
|
133
|
+
make -C util install 2>/dev/null || true
|
134
|
+
make -C lib install 2>/dev/null || true
|
135
|
+
make -C plugins/kdb/db2 install 2>/dev/null || true
|
136
|
+
}
|
137
|
+
|
138
|
+
# Verify we got the essential libraries
|
139
|
+
if [ ! -f "$KRB5_PREFIX/lib/libgssapi_krb5.a" ]; then
|
140
|
+
error "Failed to build essential Kerberos libraries"
|
141
|
+
fi
|
142
|
+
|
143
|
+
log "MIT Kerberos libraries built successfully"
|
144
|
+
else
|
145
|
+
log "MIT Kerberos already built, skipping..."
|
146
|
+
fi
|
147
|
+
|
148
|
+
cd "$BUILD_DIR"
|
149
|
+
|
150
|
+
# Build SASL
|
151
|
+
log "Building Cyrus SASL $CYRUS_SASL_VERSION for ARM64..."
|
152
|
+
SASL_PREFIX="$DEPS_PREFIX/static-sasl-$CYRUS_SASL_VERSION-arm64"
|
153
|
+
SASL_TARBALL="cyrus-sasl-$CYRUS_SASL_VERSION.tar.gz"
|
154
|
+
SASL_DIR="cyrus-sasl-$CYRUS_SASL_VERSION"
|
155
|
+
|
156
|
+
secure_download "$(get_sasl_url)" "$SASL_TARBALL"
|
157
|
+
extract_if_needed "$SASL_TARBALL" "$SASL_DIR"
|
158
|
+
cd "$SASL_DIR"
|
159
|
+
|
160
|
+
if [ ! -f "$SASL_PREFIX/lib/libsasl2.a" ]; then
|
161
|
+
log "Configuring and building SASL for ARM64..."
|
162
|
+
make clean 2>/dev/null || true
|
163
|
+
./configure --disable-shared --enable-static --prefix="$SASL_PREFIX" \
|
164
|
+
--without-dblib --disable-gdbm \
|
165
|
+
--enable-gssapi="$KRB5_PREFIX" \
|
166
|
+
CFLAGS="-fPIC" CXXFLAGS="-fPIC" \
|
167
|
+
CPPFLAGS="-I$KRB5_PREFIX/include" \
|
168
|
+
LDFLAGS="-L$KRB5_PREFIX/lib"
|
169
|
+
make -j$(get_cpu_count)
|
170
|
+
make install
|
171
|
+
log "SASL built successfully"
|
172
|
+
else
|
173
|
+
log "SASL already built, skipping..."
|
174
|
+
fi
|
175
|
+
|
176
|
+
cd "$BUILD_DIR"
|
177
|
+
|
178
|
+
# Build zlib
|
179
|
+
log "Building zlib $ZLIB_VERSION for ARM64..."
|
180
|
+
ZLIB_PREFIX="$DEPS_PREFIX/static-zlib-$ZLIB_VERSION-arm64"
|
181
|
+
ZLIB_TARBALL="zlib-$ZLIB_VERSION.tar.gz"
|
182
|
+
ZLIB_DIR="zlib-$ZLIB_VERSION"
|
183
|
+
|
184
|
+
secure_download "$(get_zlib_url)" "$ZLIB_TARBALL"
|
185
|
+
extract_if_needed "$ZLIB_TARBALL" "$ZLIB_DIR"
|
186
|
+
cd "$ZLIB_DIR"
|
187
|
+
|
188
|
+
if [ ! -f "$ZLIB_PREFIX/lib/libz.a" ]; then
|
189
|
+
log "Configuring and building zlib for ARM64..."
|
190
|
+
make clean 2>/dev/null || true
|
191
|
+
export CFLAGS="-fPIC"
|
192
|
+
./configure --prefix="$ZLIB_PREFIX" --static
|
193
|
+
make -j$(get_cpu_count)
|
194
|
+
make install
|
195
|
+
unset CFLAGS
|
196
|
+
log "zlib built successfully"
|
197
|
+
else
|
198
|
+
log "zlib already built, skipping..."
|
199
|
+
fi
|
200
|
+
|
201
|
+
cd "$BUILD_DIR"
|
202
|
+
|
203
|
+
# Build ZStd
|
204
|
+
log "Building ZStd $ZSTD_VERSION for ARM64..."
|
205
|
+
ZSTD_PREFIX="$DEPS_PREFIX/static-zstd-$ZSTD_VERSION-arm64"
|
206
|
+
ZSTD_TARBALL="zstd-$ZSTD_VERSION.tar.gz"
|
207
|
+
ZSTD_DIR="zstd-$ZSTD_VERSION"
|
208
|
+
|
209
|
+
secure_download "$(get_zstd_url)" "$ZSTD_TARBALL"
|
210
|
+
extract_if_needed "$ZSTD_TARBALL" "$ZSTD_DIR"
|
211
|
+
cd "$ZSTD_DIR"
|
212
|
+
|
213
|
+
if [ ! -f "$ZSTD_PREFIX/lib/libzstd.a" ]; then
|
214
|
+
log "Building ZStd for ARM64..."
|
215
|
+
make clean 2>/dev/null || true
|
216
|
+
make lib-mt CFLAGS="-fPIC" PREFIX="$ZSTD_PREFIX" -j$(get_cpu_count)
|
217
|
+
# Use standard install target - install-pc may not exist in all versions
|
218
|
+
make install PREFIX="$ZSTD_PREFIX"
|
219
|
+
log "ZStd built successfully"
|
220
|
+
else
|
221
|
+
log "ZStd already built, skipping..."
|
222
|
+
fi
|
223
|
+
|
224
|
+
cd "$BUILD_DIR"
|
225
|
+
|
226
|
+
# Extract and patch librdkafka
|
227
|
+
log "Extracting librdkafka..."
|
228
|
+
tar xzf "$LIBRDKAFKA_TARBALL"
|
229
|
+
cd "librdkafka-$LIBRDKAFKA_VERSION"
|
230
|
+
|
231
|
+
# Fix permissions and apply patches
|
232
|
+
fix_configure_permissions
|
233
|
+
apply_patches PATCHES_FOUND
|
234
|
+
|
235
|
+
# Configure librdkafka
|
236
|
+
log "Configuring librdkafka for ARM64..."
|
237
|
+
|
238
|
+
if [ -f configure ]; then
|
239
|
+
log "Using standard configure (autotools)"
|
240
|
+
# Export environment variables for configure to pick up
|
241
|
+
export CPPFLAGS="-I$KRB5_PREFIX/include"
|
242
|
+
export LDFLAGS="-L$KRB5_PREFIX/lib"
|
243
|
+
|
244
|
+
./configure --enable-static --disable-shared --disable-curl \
|
245
|
+
--enable-gssapi
|
246
|
+
|
247
|
+
# Clean up environment variables
|
248
|
+
unset CPPFLAGS LDFLAGS
|
249
|
+
else
|
250
|
+
error "No configure script found (checked: configure.self, configure)"
|
251
|
+
fi
|
252
|
+
|
253
|
+
# Build librdkafka
|
254
|
+
log "Compiling librdkafka for ARM64..."
|
255
|
+
make clean || true
|
256
|
+
make -j$(get_cpu_count)
|
257
|
+
|
258
|
+
# Verify librdkafka.a exists
|
259
|
+
if [ ! -f src/librdkafka.a ]; then
|
260
|
+
error "librdkafka.a not found after build"
|
261
|
+
fi
|
262
|
+
|
263
|
+
log "librdkafka.a built successfully"
|
264
|
+
|
265
|
+
# Create self-contained shared library
|
266
|
+
log "Creating self-contained librdkafka.so for ARM64..."
|
267
|
+
|
268
|
+
# Write the export map
|
269
|
+
cat > export.map <<'EOF'
|
270
|
+
{
|
271
|
+
global:
|
272
|
+
rd_kafka_*;
|
273
|
+
local:
|
274
|
+
*;
|
275
|
+
};
|
276
|
+
EOF
|
277
|
+
|
278
|
+
# Link everything statically, expose only rd_kafka_* symbols
|
279
|
+
aarch64-linux-gnu-gcc -shared -fPIC \
|
280
|
+
-Wl,--version-script=export.map \
|
281
|
+
-Wl,--whole-archive src/librdkafka.a -Wl,--no-whole-archive \
|
282
|
+
-o librdkafka.so \
|
283
|
+
"$SASL_PREFIX/lib/libsasl2.a" \
|
284
|
+
"$KRB5_PREFIX/lib/libgssapi_krb5.a" \
|
285
|
+
"$KRB5_PREFIX/lib/libkrb5.a" \
|
286
|
+
"$KRB5_PREFIX/lib/libk5crypto.a" \
|
287
|
+
"$KRB5_PREFIX/lib/libcom_err.a" \
|
288
|
+
"$KRB5_PREFIX/lib/libkrb5support.a" \
|
289
|
+
"$OPENSSL_LIB_DIR/libssl.a" \
|
290
|
+
"$OPENSSL_LIB_DIR/libcrypto.a" \
|
291
|
+
"$ZLIB_PREFIX/lib/libz.a" \
|
292
|
+
"$ZSTD_PREFIX/lib/libzstd.a" \
|
293
|
+
-lpthread -lm -ldl -lresolv
|
294
|
+
|
295
|
+
if [ ! -f librdkafka.so ]; then
|
296
|
+
error "Failed to create librdkafka.so"
|
297
|
+
fi
|
298
|
+
|
299
|
+
log "librdkafka.so created successfully"
|
300
|
+
|
301
|
+
# Verify the build
|
302
|
+
log "Verifying build..."
|
303
|
+
file librdkafka.so
|
304
|
+
|
305
|
+
log "Checking dependencies with ldd:"
|
306
|
+
ldd librdkafka.so
|
307
|
+
|
308
|
+
log "Checking for external dependencies (should only show system libraries):"
|
309
|
+
EXTERNAL_DEPS=$(nm -D librdkafka.so | grep " U " | grep -v "@GLIBC" || true)
|
310
|
+
if [ -n "$EXTERNAL_DEPS" ]; then
|
311
|
+
error "Found external dependencies - library is not self-contained: $EXTERNAL_DEPS"
|
312
|
+
else
|
313
|
+
log "✅ No external dependencies found - library is self-contained!"
|
314
|
+
fi
|
315
|
+
|
316
|
+
# Copy to output directory
|
317
|
+
OUTPUT_DIR="$SCRIPT_DIR"
|
318
|
+
cp librdkafka.so "$OUTPUT_DIR/"
|
319
|
+
log "librdkafka.so copied to: $OUTPUT_DIR/librdkafka.so"
|
320
|
+
|
321
|
+
# Print summaries
|
322
|
+
print_security_summary
|
323
|
+
print_build_summary "Linux" "aarch64 GNU" "$OUTPUT_DIR" "librdkafka.so"
|
324
|
+
|
325
|
+
# Cleanup
|
326
|
+
cleanup_build_dir "$BUILD_DIR"
|
@@ -258,7 +258,18 @@ log "librdkafka.a built successfully"
|
|
258
258
|
# Create self-contained shared library
|
259
259
|
log "Creating self-contained librdkafka.so..."
|
260
260
|
|
261
|
-
|
261
|
+
echo '
|
262
|
+
{
|
263
|
+
global:
|
264
|
+
rd_kafka_*;
|
265
|
+
local:
|
266
|
+
*;
|
267
|
+
};
|
268
|
+
' > export.map
|
269
|
+
|
270
|
+
gcc -shared -fPIC \
|
271
|
+
-Wl,--version-script=export.map \
|
272
|
+
-Wl,--whole-archive src/librdkafka.a -Wl,--no-whole-archive \
|
262
273
|
-o librdkafka.so \
|
263
274
|
"$SASL_PREFIX/lib/libsasl2.a" \
|
264
275
|
"$KRB5_PREFIX/lib/libgssapi_krb5.a" \
|
@@ -285,12 +296,12 @@ file librdkafka.so
|
|
285
296
|
log "Checking dependencies with ldd:"
|
286
297
|
ldd librdkafka.so
|
287
298
|
|
288
|
-
log "Checking for
|
289
|
-
|
290
|
-
if [ -n "$
|
291
|
-
error "Found
|
299
|
+
log "Checking for non-system library dependencies:"
|
300
|
+
NON_SYSTEM_DEPS=$(ldd librdkafka.so | grep -v -E "(linux-vdso|ld-linux|libc\.so|libpthread\.so|libm\.so|libdl\.so)" || true)
|
301
|
+
if [ -n "$NON_SYSTEM_DEPS" ]; then
|
302
|
+
error "Found non-system dependencies: $NON_SYSTEM_DEPS"
|
292
303
|
else
|
293
|
-
log "✅
|
304
|
+
log "✅ Only system dependencies found - library is portable!"
|
294
305
|
fi
|
295
306
|
|
296
307
|
# Copy to output directory
|
@@ -625,10 +625,20 @@ do
|
|
625
625
|
fi
|
626
626
|
done
|
627
627
|
|
628
|
+
echo '
|
629
|
+
{
|
630
|
+
global:
|
631
|
+
rd_kafka_*;
|
632
|
+
local:
|
633
|
+
*;
|
634
|
+
};
|
635
|
+
' > export.map
|
636
|
+
|
628
637
|
gcc -shared -fPIC \
|
629
|
-
|
630
|
-
|
631
|
-
|
638
|
+
-Wl,--version-script=export.map \
|
639
|
+
-Wl,--whole-archive src/librdkafka.a -Wl,--no-whole-archive \
|
640
|
+
-o librdkafka.so \
|
641
|
+
-Wl,-Bstatic \
|
632
642
|
"$SASL_PREFIX/lib/libsasl2.a" \
|
633
643
|
"$KRB5_PREFIX/lib/libgssapi_krb5.a" \
|
634
644
|
"$KRB5_PREFIX/lib/libkrb5.a" \
|
@@ -639,11 +649,11 @@ gcc -shared -fPIC \
|
|
639
649
|
"$OPENSSL_LIB_DIR/libcrypto.a" \
|
640
650
|
"$ZLIB_PREFIX/lib/libz.a" \
|
641
651
|
"$ZSTD_PREFIX/lib/libzstd.a" \
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
652
|
+
-Wl,-Bdynamic \
|
653
|
+
-lpthread -lm -ldl -lc \
|
654
|
+
-static-libgcc \
|
655
|
+
-Wl,--as-needed \
|
656
|
+
-Wl,--no-undefined
|
647
657
|
|
648
658
|
if [ ! -f librdkafka.so ]; then
|
649
659
|
error "Failed to create librdkafka.so"
|
data/ext/build_macos_arm64.sh
CHANGED
@@ -448,6 +448,12 @@ log "Creating self-contained librdkafka.dylib with Kerberos support..."
|
|
448
448
|
|
449
449
|
# Create self-contained shared library by linking all static dependencies (NOW INCLUDING KERBEROS)
|
450
450
|
# This is the macOS equivalent of your Linux gcc -shared command
|
451
|
+
|
452
|
+
# Write symbol export file (macOS equivalent of export.map)
|
453
|
+
cat > export_symbols.txt <<'EOF'
|
454
|
+
_rd_kafka_*
|
455
|
+
EOF
|
456
|
+
|
451
457
|
clang -dynamiclib -fPIC \
|
452
458
|
-Wl,-force_load,src/librdkafka.a \
|
453
459
|
-Wl,-force_load,"$SASL_PREFIX/lib/libsasl2.a" \
|
@@ -462,6 +468,7 @@ clang -dynamiclib -fPIC \
|
|
462
468
|
-Wl,-force_load,"$ZSTD_PREFIX/lib/libzstd.a" \
|
463
469
|
-o librdkafka.dylib \
|
464
470
|
-lpthread -lc -arch $ARCH -lresolv \
|
471
|
+
-framework GSS -framework Kerberos \
|
465
472
|
-install_name @rpath/librdkafka.dylib \
|
466
473
|
-Wl,-undefined,dynamic_lookup
|
467
474
|
|
@@ -0,0 +1,109 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
#==============================================================================
|
4
|
+
# Kafka SSL Certificate Generator
|
5
|
+
#==============================================================================
|
6
|
+
#
|
7
|
+
# DESCRIPTION:
|
8
|
+
# Generates SSL certificates for testing Kafka with SSL/TLS encryption.
|
9
|
+
# Creates both Java KeyStore (JKS) files for Kafka server and PEM files
|
10
|
+
# for client applications like rdkafka.
|
11
|
+
#
|
12
|
+
# PURPOSE:
|
13
|
+
# - Test SSL connectivity between Kafka clients and brokers
|
14
|
+
# - Validate rdkafka SSL integration
|
15
|
+
# - Enable encrypted communication for development/testing environments
|
16
|
+
#
|
17
|
+
# USAGE:
|
18
|
+
# ./ext/generate-ssl-certs.sh
|
19
|
+
# docker compose -f docker-compose-ssl.yml up
|
20
|
+
#
|
21
|
+
# REQUIREMENTS:
|
22
|
+
# - OpenSSL (for certificate generation)
|
23
|
+
# - Java keytool (usually included with JDK/JRE)
|
24
|
+
# - Write permissions in current directory
|
25
|
+
#
|
26
|
+
# OUTPUT FILES (created in ./ssl/ directory):
|
27
|
+
# ├── kafka.server.keystore.jks # Kafka server's private key and certificate
|
28
|
+
# ├── kafka.server.truststore.jks # Trusted CA certificates for Kafka
|
29
|
+
# ├── kafka_keystore_creds # Password file for keystore
|
30
|
+
# ├── kafka_truststore_creds # Password file for truststore
|
31
|
+
# ├── kafka_ssl_key_creds # Password file for SSL keys
|
32
|
+
# ├── ca-cert # CA certificate (for rdkafka clients)
|
33
|
+
# └── ca-cert.pem # CA certificate in PEM format
|
34
|
+
#
|
35
|
+
# CONFIGURATION:
|
36
|
+
# - Certificate validity: 365 days
|
37
|
+
# - Password: "confluent" (all certificates use same password for simplicity)
|
38
|
+
# - Subject: CN=localhost (suitable for local testing)
|
39
|
+
# - CA Subject: CN=localhost-ca
|
40
|
+
#
|
41
|
+
# DOCKER COMPOSE INTEGRATION:
|
42
|
+
# Use with docker-compose-ssl.yml that mounts ./ssl directory to
|
43
|
+
# /etc/kafka/secrets inside the Kafka container.
|
44
|
+
#
|
45
|
+
# RDKAFKA CLIENT CONFIGURATION:
|
46
|
+
# security.protocol=SSL
|
47
|
+
# ssl.ca.location=./ssl/ca-cert
|
48
|
+
# ssl.endpoint.identification.algorithm=none # For localhost testing
|
49
|
+
#
|
50
|
+
# NOTES:
|
51
|
+
# - Safe to run multiple times (cleans up existing files)
|
52
|
+
# - Certificates are self-signed and suitable for testing only
|
53
|
+
# - For production, use certificates signed by a trusted CA
|
54
|
+
# - All passwords are set to "confluent" for simplicity
|
55
|
+
#
|
56
|
+
#==============================================================================
|
57
|
+
|
58
|
+
# Create ssl directory and clean up any existing files
|
59
|
+
mkdir -p ssl
|
60
|
+
cd ssl
|
61
|
+
|
62
|
+
# Clean up existing files
|
63
|
+
rm -f kafka.server.keystore.jks kafka.server.truststore.jks
|
64
|
+
rm -f kafka_keystore_creds kafka_truststore_creds kafka_ssl_key_creds
|
65
|
+
rm -f ca-key ca-cert cert-file cert-signed ca-cert.srl ca-cert.pem
|
66
|
+
|
67
|
+
echo "Cleaned up existing SSL files..."
|
68
|
+
|
69
|
+
# Set variables
|
70
|
+
VALIDITY_DAYS=365
|
71
|
+
PASSWORD="confluent" # Use a simpler, well-known password
|
72
|
+
DNAME="CN=localhost,OU=Test,O=Test,L=Test,ST=Test,C=US"
|
73
|
+
|
74
|
+
# Create password files (all same password for simplicity)
|
75
|
+
echo "$PASSWORD" > kafka_keystore_creds
|
76
|
+
echo "$PASSWORD" > kafka_truststore_creds
|
77
|
+
echo "$PASSWORD" > kafka_ssl_key_creds
|
78
|
+
|
79
|
+
# Step 1: Generate CA key and certificate
|
80
|
+
openssl req -new -x509 -keyout ca-key -out ca-cert -days $VALIDITY_DAYS -subj "/CN=localhost-ca/OU=Test/O=Test/L=Test/S=Test/C=US" -passin pass:$PASSWORD -passout pass:$PASSWORD
|
81
|
+
|
82
|
+
# Step 2: Create truststore and import the CA certificate
|
83
|
+
keytool -keystore kafka.server.truststore.jks -alias CARoot -import -file ca-cert -storepass $PASSWORD -keypass $PASSWORD -noprompt
|
84
|
+
|
85
|
+
# Step 3: Create keystore
|
86
|
+
keytool -keystore kafka.server.keystore.jks -alias localhost -validity $VALIDITY_DAYS -genkey -keyalg RSA -dname "$DNAME" -storepass $PASSWORD -keypass $PASSWORD
|
87
|
+
|
88
|
+
# Step 4: Create certificate signing request
|
89
|
+
keytool -keystore kafka.server.keystore.jks -alias localhost -certreq -file cert-file -storepass $PASSWORD -keypass $PASSWORD
|
90
|
+
|
91
|
+
# Step 5: Sign the certificate with the CA
|
92
|
+
openssl x509 -req -CA ca-cert -CAkey ca-key -in cert-file -out cert-signed -days $VALIDITY_DAYS -CAcreateserial -passin pass:$PASSWORD
|
93
|
+
|
94
|
+
# Step 6: Import CA certificate into keystore
|
95
|
+
keytool -keystore kafka.server.keystore.jks -alias CARoot -import -file ca-cert -storepass $PASSWORD -keypass $PASSWORD -noprompt
|
96
|
+
|
97
|
+
# Step 7: Import signed certificate into keystore
|
98
|
+
keytool -keystore kafka.server.keystore.jks -alias localhost -import -file cert-signed -storepass $PASSWORD -keypass $PASSWORD -noprompt
|
99
|
+
|
100
|
+
# Export CA certificate to PEM format for rdkafka
|
101
|
+
cp ca-cert ca-cert.pem
|
102
|
+
|
103
|
+
# Clean up intermediate files (but keep ca-cert.pem for rdkafka)
|
104
|
+
rm ca-key cert-file cert-signed
|
105
|
+
|
106
|
+
echo "SSL certificates generated successfully!"
|
107
|
+
echo "Password: $PASSWORD"
|
108
|
+
echo ""
|
109
|
+
echo "For rdkafka, use ca-cert.pem or ca-cert files"
|
data/ext/librdkafka.dylib
CHANGED
Binary file
|
data/karafka-rdkafka.gemspec
CHANGED
@@ -41,15 +41,17 @@ Gem::Specification.new do |gem|
|
|
41
41
|
end
|
42
42
|
|
43
43
|
gem.add_dependency 'ffi', '~> 1.15'
|
44
|
+
gem.add_dependency 'json', '> 2.0'
|
44
45
|
gem.add_dependency 'logger'
|
45
46
|
gem.add_dependency 'mini_portile2', '~> 2.6'
|
46
|
-
gem.add_dependency 'ostruct'
|
47
47
|
gem.add_dependency 'rake', '> 12'
|
48
48
|
|
49
|
+
gem.add_development_dependency 'ostruct'
|
49
50
|
gem.add_development_dependency 'pry'
|
50
51
|
gem.add_development_dependency 'rspec', '~> 3.5'
|
51
52
|
gem.add_development_dependency 'rake'
|
52
53
|
gem.add_development_dependency 'simplecov'
|
54
|
+
gem.add_development_dependency 'warning'
|
53
55
|
|
54
56
|
gem.metadata = {
|
55
57
|
'funding_uri' => 'https://karafka.io/#become-pro',
|