Repository navigation
build(repeater): bundle the PKCS#11 provider with the Windows executable - #819
Merged
Merged
Conversation
- Add the pkcs11js addon to pkg.assets so the executables can use it. - The temporary build chain now assembles bright-cli-win-x64-smartcard: bright-cli.exe, libp11's pkcs11prov.dll, the libcrypto-3-x64.dll it imports, and their licence notices. - tests/pkcs11/repeater-smoke.ts stands in for the Bright cloud and sends a built Repeater one request. The workflow runs it against the bundle on windows-2022 with a SoftHSM2 token and a PATH stripped to Node and Windows, so the executable must find everything next to itself: 200 with the right PIN, PKCS11_PIN_INCORRECT with a wrong one.
The bundled Windows executable failed with "SSL crypto engine not found": OpenSSL reads OPENSSL_CONF through the C runtime's getenv(), which on Windows only sees the environment at process start, so the config the Repeater generates at runtime was never loaded. The tests passed only because their environment also set OPENSSL_MODULES and PKCS11_MODULE_PATH. Set OPENSSL_WIN32_UTF8 so OpenSSL reads variables through GetEnvironmentVariableW, and run the SoftHSM suite and the bundle smoke test without those helper variables. On ubi8, pkcs11js did not compile: node-gyp needs Python 3.8+ and Node 24's headers need C++20, while ubi8 ships Python 3.6 and gcc 8. Build with python3.11 and gcc-toolset-12, in the release workflow as well.
- Ship vcruntime140.dll in the Windows bundle: libcrypto-3-x64.dll imports it, so without the VC++ redistributable the provider would not load. A new step checks that every DLL the bundle imports is in the bundle or part of Windows. - Build the pkcs11js addon for x64 on the arm64 macOS runners, and check the addon's architecture before packaging, in the release workflow too. - Set SSLENGINE once per pooled handle: curl reloads OPENSSL_CONF into the handle's library context on every call, which on Windows leaks the path each time. - repeater-smoke.ts stops the Repeater on every outcome, not only on success, and accepts "error" for any errorCode without a status. - Pin the licence files by SHA-256 and wait for the smoke target to listen instead of sleeping.
aborovsky
added a commit
that referenced
this pull request
Nov 11, 2026
…target (#820) ## What Two scripts that send one request through the Repeater, built from this checkout, to a **remote** target that requires client certificates. The client key sits on a throwaway SoftHSM2 token. `setup.sh` and the local target are not used, and no API key is needed: `repeater-smoke.ts` stands in for the Bright cloud. | Script | Certificate on the token | Expected | |---|---|---| | `tests/pkcs11/remote/positive.sh <url> <client.p12> [password] [status]` | the given PKCS#12, issued by a CA the target trusts | HTTP status (default 200) | | `tests/pkcs11/remote/negative.sh <url> [client.p12] [password]` | a self-signed certificate, or the given PKCS#12 from another CA | the target rejects it in the TLS handshake: an `errorCode`, no HTTP status | The negative case relies on `repeater-smoke.ts` accepting `error` as the expected result, which came with #819. ## Checked Against an `ao-https-with-header` mock that trusts `MyCompany Root CA` (AWS NLB with TLS passthrough): - positive, `CN=alice@example.com`: `SMOKE PASSED: 200` (`Certificate is valid!`); - negative, self-signed: `SMOKE PASSED: error` (`ECONNRESET`, "Failure when receiving data from the peer"); - negative, `CN=Hacker` issued by `Evil CA`: `SMOKE PASSED: error`. shellcheck is clean.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A Windows bundle that a tester can unzip and run against a smart card, with no other install than the card vendor's PKCS#11 module.
The temporary build chain now uploads
bright-cli-win-x64-smartcard:bright-cli.exepkcs11jsaddonpkcs11prov.dlllibcrypto-3-x64.dllpkcs11prov.dllimports (from the runner's OpenSSL install; the version is recorded in the notices)vcruntime140.dlllibcrypto-3-x64.dllimports, so the VC++ redistributable is not requiredLICENSE-libp11.txt,LICENSE-OpenSSL.txt,THIRD-PARTY-NOTICES.txtThe Repeater already looks for
pkcs11prov.dllnext to its executable. Windows resolves the provider'slibcrypto-3-x64.dllfrom the same folder.Smoke test of the real artifact
tests/pkcs11/repeater-smoke.tsstands in for the Bright cloud onlocalhost:8000: the same socket.io path, namespace and msgpack parser as the bridges. It waits for the Repeater to deploy, sends it one request and checks the result.On windows-2022, the workflow runs it against the bundled
bright-cli.exewith a SoftHSM2 token and an mTLS target.PATHis stripped to Node and Windows, so a DLL missing from the bundle cannot be found elsewhere.200, and the target reports the client certificate from the token;PKCS11_PIN_INCORRECT.socket.iois added as a dev dependency for the fake cloud.Review fixes
vcruntime140.dll. A new step checks that every DLL the bundle imports is either in the bundle or part of Windows.pkcs11jsaddon is rebuilt for x64, the architecture of the executable. Before packaging, the architecture of the addon is read from its ELF, Mach-O or PE header and checked. The releasedeploy.ymlgets the same steps.SSLENGINEis set once per pooled handle. curl reloadsOPENSSL_CONFinto the handle's library context on every call, which on Windows leaks the path each time.repeater-smoke.tsstops the Repeater on every outcome, not only on success, and acceptserrorfor any errorCode without a status.Checks
node dist/index.js(200 andPKCS11_PIN_INCORRECT) and with a pkg executable built from this branch (200).pkcs11jsaddon did not compile. As an optional dependency, a failed compile would otherwise only show up at runtime.Not in this PR
pkcs11jsprebuilds, the Docker image, Helm and npm docs.libcrypto-3-x64.dllinstead of taking it from the runner image.