]> git.kaiwu.me - njs.git/commit
Modules: fixed loading of the built-in "crypto" module.
authorDmitry Volyntsev <xeioex@nginx.com>
Wed, 22 Apr 2026 22:56:18 +0000 (15:56 -0700)
committerDmitry Volyntsev <xeioexception@gmail.com>
Thu, 23 Apr 2026 15:05:12 +0000 (08:05 -0700)
commit3f660998610de5e82e5627b2fb86f8513e9fdca5
tree5206f9e47545eec3c5e3f05b6febde18c662ed49
parentffc95c01ed8bfb834b1b017f08f83d40b8701629
Modules: fixed loading of the built-in "crypto" module.

Since 3185ce81 (0.9.7), njs_crypto_module has been registered
conditionally in auto/modules under NJS_HAVE_OPENSSL.  libnjs.a is
built for the nginx module via nginx/config.make with
"./configure --no-openssl ...", so libnjs.a's njs_modules[] no
longer contains the crypto module.  The nginx addon lists
(njs_http_js_addon_modules[] and njs_stream_js_addon_modules[],
plus the qjs variants) were not updated accordingly, making
"import cr from 'crypto'" fail at nginx -t with ENOENT.

Added &njs_crypto_module and &qjs_crypto_module to the shared addon
list under the existing NJS_HAVE_OPENSSL guard, next to the webcrypto
entries.

While here, the near-identical addon arrays were factored into
shared macros in a new header nginx/ngx_js_modules.h, so adding a
future conditional addon needs a single edit instead of four.

This closes #1049 issue on Github.
nginx/config
nginx/ngx_http_js_module.c
nginx/ngx_js.h
nginx/ngx_js_modules.h [new file with mode: 0644]
nginx/ngx_stream_js_module.c
nginx/t/js_crypto.t [new file with mode: 0644]
nginx/t/stream_js_crypto.t [new file with mode: 0644]