Skip to content

Commit 1298e48

Browse files
divybotlittledivy
andauthored
fix(ext/node): throw OpenSSL-shaped error from tls.createSecureContext when clientCertEngine is set (#33691)
## Summary Enables `test-tls-error-stack` in node_compat suite. ## Test plan - [x] `cargo test --test node_compat -- test-tls-error-stack` Co-authored-by: Divy Srivastava <me@littledivy.com>
1 parent 2c92763 commit 1298e48

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

ext/node/polyfills/_tls_common.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,22 @@ export class SecureContext {
333333
}
334334
if (options.clientCertEngine != null) {
335335
validateString(options.clientCertEngine, "options.clientCertEngine");
336+
// OpenSSL engines are not supported in Deno (which uses rustls).
337+
// Match Node's behaviour when OpenSSL fails to load the engine: throw
338+
// an Error whose message contains "could not load the shared library"
339+
// and carries an `opensslErrorStack` array.
340+
const err = new Error(
341+
`error:25066067:DSO support routines:dlfcn_load:could not load the shared library`,
342+
) as any;
343+
err.opensslErrorStack = [
344+
`error:25070067:DSO support routines:DSO_load:could not load the shared library`,
345+
`error:260B6084:engine routines:dynamic_load:dso not found`,
346+
];
347+
err.library = "DSO support routines";
348+
err.function = "dlfcn_load";
349+
err.reason = "could not load the shared library";
350+
err.code = "ERR_OSSL_DSO_COULD_NOT_LOAD_THE_SHARED_LIBRARY";
351+
throw err;
336352
}
337353
if (options.privateKeyEngine != null) {
338354
validateString(options.privateKeyEngine, "options.privateKeyEngine");

tests/node_compat/config.jsonc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3480,6 +3480,7 @@
34803480
"parallel/test-tls-empty-sni-context.js": {},
34813481
"parallel/test-tls-enable-trace-cli.js": {},
34823482
"parallel/test-tls-enable-trace.js": {},
3483+
"parallel/test-tls-error-stack.js": {},
34833484
"parallel/test-tls-env-extra-ca-no-crypto.js": {},
34843485
"parallel/test-tls-external-accessor.js": {},
34853486
"parallel/test-tls-fast-writing.js": {},

0 commit comments

Comments
 (0)