[njs] Modules: fixed building when http_ssl and stream_ssl unavailable.

noreply at nginx.com noreply at nginx.com
Thu Sep 18 00:37:02 UTC 2025


details:   https://github.com/nginx/njs/commit/4ea1356af08e714076f57d02575f7845d6e80795
branches:  master
commit:    4ea1356af08e714076f57d02575f7845d6e80795
user:      Dmitry Volyntsev <xeioex at nginx.com>
date:      Wed, 17 Sep 2025 15:34:19 -0700
description:
Modules: fixed building when http_ssl and stream_ssl unavailable.

This fixes issue introduced in 7b3c8a66.

---
 .github/workflows/check-pr.yml | 20 +++++++++++++++++++-
 nginx/ngx_http_js_module.c     |  6 +++---
 nginx/ngx_js.c                 |  4 ++--
 nginx/ngx_js.h                 |  2 +-
 nginx/ngx_js_http.c            |  4 ++++
 nginx/ngx_stream_js_module.c   |  6 +++---
 nginx/t/js_webcrypto.t         | 17 +++++++++++++++--
 nginx/t/stream_js_webcrypto.t  | 30 +++++++++++++++++++++++++++---
 8 files changed, 74 insertions(+), 15 deletions(-)

diff --git a/.github/workflows/check-pr.yml b/.github/workflows/check-pr.yml
index c75f3cbe..d5e0edd2 100644
--- a/.github/workflows/check-pr.yml
+++ b/.github/workflows/check-pr.yml
@@ -12,7 +12,10 @@ jobs:
 
       - name: Set the defaults and set up environment
         run: |
-          echo NGINX_CONFIGURE_CMD="auto/configure --prefix=/tmp --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-mail --with-mail_ssl_module --with-select_module --with-poll_module --with-http_auth_request_module --with-http_v2_module --with-http_slice_module --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module --with-stream_realip_module --with-threads --with-cpp_test_module --with-compat --with-http_degradation_module --with-http_xslt_module --with-http_image_filter_module --with-http_perl_module --with-http_geoip_module --with-stream_geoip_module" >> $GITHUB_ENV
+          NGINX_BASE="auto/configure --prefix=/tmp --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-mail --with-select_module --with-poll_module --with-http_auth_request_module --with-http_v2_module --with-http_slice_module --with-stream --with-stream_realip_module --with-threads --with-cpp_test_module --with-compat --with-http_degradation_module --with-http_xslt_module --with-http_image_filter_module --with-http_perl_module --with-http_geoip_module --with-stream_geoip_module"
+          SSL_MODULES="--with-http_ssl_module --with-mail_ssl_module --with-stream_ssl_module --with-stream_ssl_preread_module"
+          echo NGINX_CONFIGURE_CMD="$NGINX_BASE $SSL_MODULES" >> $GITHUB_ENV
+          echo NGINX_CONFIGURE_CMD_NO_SSL="$NGINX_BASE" >> $GITHUB_ENV
           export DEB_BUILD_MAINT_OPTIONS="hardening=+all"
           export DEB_CFLAGS_MAINT_APPEND="-fPIC"
           export DEB_LDFLAGS_MAINT_APPEND=""-Wl,--as-needed""
@@ -126,6 +129,21 @@ jobs:
           TEST_NGINX_GLOBALS: "load_module ${{ github.workspace }}/nginx-source/objs/ngx_http_js_module.so; load_module ${{ github.workspace }}/nginx-source/objs/ngx_stream_js_module.so;"
           TEST_NGINX_VERBOSE: 1
 
+      - name: Configure and build nginx and njs modules, no SSL, static modules
+        run: |
+          cd nginx-source
+          NJS_OPENSSL=NO $NGINX_CONFIGURE_CMD_NO_SSL --with-cc-opt="$CC_OPT" --with-ld-opt="$LD_OPT" --add-module=../nginx || cat objs/autoconf.err
+          $MAKE_UTILITY -j$(nproc) modules
+          $MAKE_UTILITY -j$(nproc)
+
+      - name: Test njs modules, no SSL, static modules
+        run: |
+          ulimit -c unlimited
+          prove -v -j$(nproc) -Inginx-tests/lib --state=save nginx/t . || prove -v -Inginx-tests/lib --state=failed
+        env:
+          TEST_NGINX_BINARY: "${{ github.workspace }}/nginx-source/objs/nginx"
+          TEST_NGINX_VERBOSE: 1
+
       - name: Create LSAN suppression file
         run: |
           cat << EOF > lsan_suppressions.txt
diff --git a/nginx/ngx_http_js_module.c b/nginx/ngx_http_js_module.c
index f9d9721a..2f3ce936 100644
--- a/nginx/ngx_http_js_module.c
+++ b/nginx/ngx_http_js_module.c
@@ -400,7 +400,7 @@ static ngx_conf_bitmask_t  ngx_http_js_engines[] = {
     { ngx_null_string, 0 }
 };
 
-#if (NGX_HTTP_SSL)
+#if (NGX_SSL)
 
 static ngx_conf_bitmask_t  ngx_http_js_ssl_protocols[] = {
     { ngx_string("TLSv1"), NGX_SSL_TLSv1 },
@@ -519,7 +519,7 @@ static ngx_command_t  ngx_http_js_commands[] = {
       offsetof(ngx_http_js_loc_conf_t, timeout),
       NULL },
 
-#if (NGX_HTTP_SSL)
+#if (NGX_SSL)
 
     { ngx_string("js_fetch_ciphers"),
       NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
@@ -8172,7 +8172,7 @@ ngx_http_js_create_loc_conf(ngx_conf_t *cf)
         return NULL;
     }
 
-#if (NGX_HTTP_SSL)
+#if (NGX_SSL)
     conf->ssl_verify = NGX_CONF_UNSET;
     conf->ssl_verify_depth = NGX_CONF_UNSET;
 #endif
diff --git a/nginx/ngx_js.c b/nginx/ngx_js.c
index efef3467..053c23c2 100644
--- a/nginx/ngx_js.c
+++ b/nginx/ngx_js.c
@@ -3996,7 +3996,7 @@ ngx_js_create_conf(ngx_conf_t *cf, size_t size)
 }
 
 
-#if defined(NGX_HTTP_SSL) || defined(NGX_STREAM_SSL)
+#if (NGX_SSL)
 
 static ngx_int_t
 ngx_js_merge_ssl(ngx_conf_t *cf, ngx_js_loc_conf_t *conf,
@@ -4122,7 +4122,7 @@ ngx_js_merge_conf(ngx_conf_t *cf, void *parent, void *child,
         return NGX_CONF_ERROR;
     }
 
-#if defined(NGX_HTTP_SSL) || defined(NGX_STREAM_SSL)
+#if (NGX_SSL)
 
     if (ngx_js_merge_ssl(cf, conf, prev) != NGX_OK) {
         return NGX_CONF_ERROR;
diff --git a/nginx/ngx_js.h b/nginx/ngx_js.h
index af19e007..20ea85b1 100644
--- a/nginx/ngx_js.h
+++ b/nginx/ngx_js.h
@@ -144,7 +144,7 @@ typedef struct {
     ngx_queue_t            fetch_keepalive_free
 
 
-#if defined(NGX_HTTP_SSL) || defined(NGX_STREAM_SSL)
+#if (NGX_SSL)
 #define NGX_JS_COMMON_LOC_CONF                                                \
     _NGX_JS_COMMON_LOC_CONF;                                                  \
                                                                               \
diff --git a/nginx/ngx_js_http.c b/nginx/ngx_js_http.c
index f07ccceb..35c67842 100644
--- a/nginx/ngx_js_http.c
+++ b/nginx/ngx_js_http.c
@@ -1643,9 +1643,11 @@ ngx_js_http_get_keepalive_connection(ngx_js_http_t *http)
             continue;
         }
 
+#if (NGX_SSL)
         if ((http->ssl != NULL) != (cache->ssl != 0)) {
             continue;
         }
+#endif
 
         if (ngx_strncasecmp(host->data, cache->host, host->len) != 0) {
             continue;
@@ -1775,7 +1777,9 @@ ngx_js_http_free_keepalive_connection(ngx_js_http_t *http)
 
     cache->connection = c;
 
+#if (NGX_SSL)
     cache->ssl = (http->ssl != NULL);
+#endif
     ngx_memcpy(cache->host, http->host.data, http->host.len);
     cache->host_len = http->host.len;
     cache->port = http->port;
diff --git a/nginx/ngx_stream_js_module.c b/nginx/ngx_stream_js_module.c
index ab4e787d..212af400 100644
--- a/nginx/ngx_stream_js_module.c
+++ b/nginx/ngx_stream_js_module.c
@@ -232,7 +232,7 @@ static ngx_conf_bitmask_t  ngx_stream_js_engines[] = {
     { ngx_null_string, 0 }
 };
 
-#if (NGX_STREAM_SSL)
+#if (NGX_SSL)
 
 static ngx_conf_bitmask_t  ngx_stream_js_ssl_protocols[] = {
     { ngx_string("TLSv1"), NGX_SSL_TLSv1 },
@@ -379,7 +379,7 @@ static ngx_command_t  ngx_stream_js_commands[] = {
       offsetof(ngx_stream_js_srv_conf_t, fetch_keepalive_timeout),
       NULL },
 
-#if (NGX_STREAM_SSL)
+#if (NGX_SSL)
 
     { ngx_string("js_fetch_ciphers"),
       NGX_STREAM_MAIN_CONF|NGX_STREAM_SRV_CONF|NGX_CONF_TAKE1,
@@ -3620,7 +3620,7 @@ ngx_stream_js_create_srv_conf(ngx_conf_t *cf)
         return NULL;
     }
 
-#if (NGX_STREAM_SSL)
+#if (NGX_SSL)
     conf->ssl_verify = NGX_CONF_UNSET;
     conf->ssl_verify_depth = NGX_CONF_UNSET;
 #endif
diff --git a/nginx/t/js_webcrypto.t b/nginx/t/js_webcrypto.t
index f43f9d6d..33869574 100644
--- a/nginx/t/js_webcrypto.t
+++ b/nginx/t/js_webcrypto.t
@@ -41,6 +41,10 @@ http {
         listen       127.0.0.1:8080;
         server_name  localhost;
 
+        location /has_crypto {
+            js_content test.has_crypto;
+        }
+
         location /random_values_test {
             js_content test.random_values_test;
         }
@@ -50,6 +54,10 @@ http {
 EOF
 
 $t->write_file('test.js', <<EOF);
+    function has_crypto(r) {
+        r.return(200, (crypto !== undefined).toString());
+    }
+
     function count1(v) {
         return v.toString(2).match(/1/g).length;
     }
@@ -72,11 +80,16 @@ $t->write_file('test.js', <<EOF);
         r.return(200, bits1 > (mean - 10 * stdd) && bits1 < (mean + 10 * stdd));
     }
 
-    export default {random_values_test};
+    export default {has_crypto, random_values_test};
 
 EOF
 
-$t->try_run('no njs')->plan(1);
+$t->try_run('no njs');
+
+plan(skip_all => 'njs crypto module not available')
+	if http_get('/has_crypto') !~ /true/;
+
+$t->plan(1);
 
 ###############################################################################
 
diff --git a/nginx/t/stream_js_webcrypto.t b/nginx/t/stream_js_webcrypto.t
index d7b34396..619a093d 100644
--- a/nginx/t/stream_js_webcrypto.t
+++ b/nginx/t/stream_js_webcrypto.t
@@ -23,7 +23,7 @@ use Test::Nginx::Stream qw/ stream /;
 select STDERR; $| = 1;
 select STDOUT; $| = 1;
 
-my $t = Test::Nginx->new()->has(qw/stream stream_return/)
+my $t = Test::Nginx->new()->has(qw/http stream stream_return/)
 	->write_file_expand('nginx.conf', <<'EOF');
 
 %%TEST_GLOBALS%%
@@ -33,6 +33,21 @@ daemon off;
 events {
 }
 
+http {
+    %%TEST_GLOBALS_HTTP%%
+
+    js_import test.js;
+
+    server {
+        listen       127.0.0.1:8080;
+        server_name  localhost;
+
+        location /has_crypto {
+            js_content test.has_crypto;
+        }
+    }
+}
+
 stream {
     %%TEST_GLOBALS_STREAM%%
 
@@ -49,6 +64,10 @@ stream {
 EOF
 
 $t->write_file('test.js', <<EOF);
+    function has_crypto(r) {
+        r.return(200, (crypto !== undefined).toString());
+    }
+
     function count1(v) {
         return v.toString(2).match(/1/g).length;
     }
@@ -71,10 +90,15 @@ $t->write_file('test.js', <<EOF);
         return bits1 > (mean - 10 * stdd) && bits1 < (mean + 10 * stdd);
     }
 
-    export default {random_values_test};
+    export default {has_crypto, random_values_test};
 EOF
 
-$t->try_run('no stream js_var')->plan(1);
+$t->try_run('no stream js_var');
+
+plan(skip_all => 'njs crypto module not available')
+	if http_get('/has_crypto') !~ /true/;
+
+$t->plan(1);
 
 ###############################################################################
 


More information about the nginx-devel mailing list