Skip to content

Commit 0ebc953

Browse files
kranurag7EyeCantCUjamonation
authored
dynamically link kong to system openssl (#39663)
links to system openssl. ```bash $ scanelf /usr/local/ -R | awk '{print $2}' | xargs ldd | grep -E 'libssl|libcrypto' ldd: ./FILE: No such file or directory libssl.so.3 => /usr/lib/libssl.so.3 (0x00007c626fcbd000) libcrypto.so.3 => /usr/lib/libcrypto.so.3 (0x00007c626f600000) libssl.so.3 => /usr/lib/libssl.so.3 (0x00007a43aab8d000) libcrypto.so.3 => /usr/lib/libcrypto.so.3 (0x00007a43aa600000) libssl.so.3 => /usr/lib/libssl.so.3 (0x00007bd661c20000) libcrypto.so.3 => /usr/lib/libcrypto.so.3 (0x00007bd661600000) ``` --------- Signed-off-by: kranurag7 <[email protected]> Co-authored-by: RJ Trujillo <[email protected]> Co-authored-by: Jamon Camisso <[email protected]>
1 parent 895667e commit 0ebc953

File tree

2 files changed

+129
-3
lines changed

2 files changed

+129
-3
lines changed

kong.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package:
22
name: kong
33
version: 3.9.0
4-
epoch: 1
4+
epoch: 2
55
description: "The Kong Gateway - an API Gateway built on Nginx and OpenResty"
66
copyright:
77
- license: Apache-2.0
@@ -47,9 +47,11 @@ pipeline:
4747

4848
- uses: patch
4949
with:
50-
patches: http-archive.patch
50+
patches: http-archive.patch openssl.patch
5151

5252
- runs: |
53+
# remove openssl directory given we want to build against our system openssl.
54+
rm -r build/openresty/openssl
5355
# Set up environment variables
5456
export PATH=$PATH:$HOME/.cargo/bin
5557
export JAVA_HOME=/usr/lib/jvm/java-21-openjdk
@@ -82,4 +84,6 @@ update:
8284
test:
8385
pipeline:
8486
- runs: |
85-
kong version
87+
kong version | grep -i ${{package.version}}
88+
kong prepare --v 2>/dev/null | grep -i "preparing nginx"
89+
kong roar | grep -i "Monolith destroyer"

kong/openssl.patch

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
diff --git a/build/BUILD.bazel b/build/BUILD.bazel
2+
index b83f4f4..42aa986 100644
3+
--- a/build/BUILD.bazel
4+
+++ b/build/BUILD.bazel
5+
@@ -10,7 +10,6 @@ exports_files([
6+
# C libraries
7+
8+
clib_deps = [
9+
- "@openssl",
10+
"@libexpat",
11+
"@snappy",
12+
"@ada",
13+
@@ -21,7 +20,7 @@ clib_deps = [
14+
name = "install-%s" % get_workspace_name(k),
15+
src = k,
16+
# only install openssl headers
17+
- exclude = [] if k in ("@openssl",) else ["include"],
18+
+ exclude = ["include"],
19+
prefix = "kong/lib" if k in ("@passwdqc", "@snappy", "@ada") else "kong",
20+
strip_path = "snappy" if k == "@snappy" else "ada" if k == "@ada" else "",
21+
)
22+
@@ -47,7 +46,6 @@ kong_rules_group(
23+
kong_rules_group(
24+
name = "cacheable-targets",
25+
propagates = [
26+
- "@openssl",
27+
"@libexpat",
28+
"@atc_router",
29+
"@simdjson_ffi",
30+
@@ -73,7 +71,6 @@ kong_install(
31+
prefix = "openresty",
32+
deps = [
33+
":install-openresty-luajit",
34+
- ":install-openssl",
35+
],
36+
)
37+
38+
diff --git a/build/luarocks/BUILD.luarocks.bazel b/build/luarocks/BUILD.luarocks.bazel
39+
index b23ad96..d9dda79 100644
40+
--- a/build/luarocks/BUILD.luarocks.bazel
41+
+++ b/build/luarocks/BUILD.luarocks.bazel
42+
@@ -40,7 +40,6 @@ kong_template_genrule(
43+
name = "luarocks_exec",
44+
srcs = [
45+
"@libexpat",
46+
- "@openssl",
47+
] + select({
48+
"@kong//:any-cross": ["@cross_deps_libyaml//:libyaml"],
49+
"//conditions:default": [
50+
diff --git a/build/luarocks/templates/luarocks_exec.sh b/build/luarocks/templates/luarocks_exec.sh
51+
index 10515f8..f8cc445 100644
52+
--- a/build/luarocks/templates/luarocks_exec.sh
53+
+++ b/build/luarocks/templates/luarocks_exec.sh
54+
@@ -3,7 +3,6 @@
55+
# template variables starts
56+
libexpat_path="{{@@libexpat//:libexpat}}"
57+
libxml2_path="invalid"
58+
-openssl_path="{{@@openssl//:openssl}}"
59+
luarocks_host_path="{{@@luarocks//:luarocks_host}}"
60+
luajit_path="{{@@openresty//:luajit}}"
61+
kongrocks_path="invalid"
62+
@@ -27,7 +26,6 @@ ROCKS_CONFIG=$(readlink -f "$ROCKS_DIR/../luarocks_config.lua")
63+
64+
EXPAT_DIR=$root_path/$libexpat_path
65+
LIBXML2_DIR=$root_path/$libxml2_path
66+
-OPENSSL_DIR=$root_path/$openssl_path
67+
68+
# The Bazel rules doesn't export the `libexpat.so` file,
69+
# it only exports something like `libexpat.so.1.6.0`,
70+
@@ -115,8 +113,6 @@ fi
71+
# some distros has BINPRM_BUF_SIZE smaller than the shebang generated,
72+
# which is usually more than 160 bytes
73+
$host_luajit $root_path/$LUAROCKS_HOST/bin/luarocks \$private_rocks_args \$@ \\
74+
- OPENSSL_DIR=$OPENSSL_DIR \\
75+
- CRYPTO_DIR=$OPENSSL_DIR \\
76+
EXPAT_DIR=$EXPAT_DIR \\
77+
LIBXML2_DIR=$LIBXML2_DIR \\
78+
YAML_DIR=$YAML_DIR
79+
diff --git a/build/openresty/BUILD.openresty.bazel b/build/openresty/BUILD.openresty.bazel
80+
index 81ad172..157f6b7 100644
81+
--- a/build/openresty/BUILD.openresty.bazel
82+
+++ b/build/openresty/BUILD.openresty.bazel
83+
@@ -147,10 +147,8 @@ CONFIGURE_OPTIONS = [
84+
"--without-http_rds_csv_module",
85+
"--with-luajit=$$EXT_BUILD_DEPS/luajit",
86+
"--with-cc-opt=\"-I$$EXT_BUILD_DEPS/pcre/include\"",
87+
- "--with-cc-opt=\"-I$$EXT_BUILD_DEPS/openssl/include\"",
88+
"--with-cc-opt=\"-I$$EXT_BUILD_DEPS/luajit/include\"",
89+
"--with-ld-opt=\"-L$$EXT_BUILD_DEPS/pcre/lib\"",
90+
- "--with-ld-opt=\"-L$$EXT_BUILD_DEPS/openssl/lib\"",
91+
"--with-ld-opt=\"-L$$EXT_BUILD_DEPS/luajit/lib\"",
92+
"--with-ld-opt=\"-L$$EXT_BUILD_DEPS/lib\"",
93+
# Here let's try not having --disable-new-dtags; --disable-new-dtags creates rpath instead of runpath
94+
@@ -326,7 +324,6 @@ configure_make(
95+
visibility = ["//visibility:public"],
96+
deps = [
97+
"@openresty//:luajit",
98+
- "@openssl",
99+
"@pcre",
100+
] + select({
101+
"@kong//:any-cross": [
102+
diff --git a/build/openresty/repositories.bzl b/build/openresty/repositories.bzl
103+
index f4cafe9..6ced994 100644
104+
--- a/build/openresty/repositories.bzl
105+
+++ b/build/openresty/repositories.bzl
106+
@@ -7,7 +7,6 @@ load("//build:build_system.bzl", "git_or_local_repository")
107+
load("//build/openresty/ada:ada_repositories.bzl", "ada_repositories")
108+
load("//build/openresty/atc_router:atc_router_repositories.bzl", "atc_router_repositories")
109+
load("//build/openresty/brotli:brotli_repositories.bzl", "brotli_repositories")
110+
-load("//build/openresty/openssl:openssl_repositories.bzl", "openssl_repositories")
111+
load("//build/openresty/pcre:pcre_repositories.bzl", "pcre_repositories")
112+
load("//build/openresty/simdjson_ffi:simdjson_ffi_repositories.bzl", "simdjson_ffi_repositories")
113+
load("//build/openresty/snappy:snappy_repositories.bzl", "snappy_repositories")
114+
@@ -31,7 +30,6 @@ filegroup(
115+
116+
def openresty_repositories():
117+
pcre_repositories()
118+
- openssl_repositories()
119+
simdjson_ffi_repositories()
120+
atc_router_repositories()
121+
wasmx_repositories()
122+

0 commit comments

Comments
 (0)