crypto: add crypto::GetSSLCtx API for addon access to OpenSSL contexts#62254
Merged
Conversation
Collaborator
|
Review requested:
|
This intended to replace usage of the unsupported _external field, offering an official API for native addons to access OpenSSL directly while reducing the JS API and internal field exposure.
Codecov Reportโ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #62254 +/- ##
==========================================
- Coverage 89.66% 89.66% -0.01%
==========================================
Files 676 676
Lines 206500 206572 +72
Branches 39539 39555 +16
==========================================
+ Hits 185168 185231 +63
+ Misses 13463 13459 -4
- Partials 7869 7882 +13
๐ New features to boost your workflow:
|
addaleax
reviewed
Mar 15, 2026
addaleax
approved these changes
Mar 15, 2026
Collaborator
Collaborator
Collaborator
Collaborator
Collaborator
Collaborator
Commit Queue failed- Loading data for nodejs/node/pull/62254 โ Done loading data for nodejs/node/pull/62254 ----------------------------------- PR info ------------------------------------ Title crypto: add crypto::GetSSLCtx API for addon access to OpenSSL contexts (#62254) โ Could not retrieve the email or name of the PR author's from user's GitHub profile! Branch pimterry:getsslctx-api -> nodejs:main Labels crypto, c++, needs-ci, commit-queue-squash Commits 2 - crypto: add crypto::GetSSLCtx API for addon access to OpenSSL contexts - Handle JS getter exceptions in GetSSLCtx Committers 1 - Tim Perry <pimterry@gmail.com> PR-URL: https://github.com/nodejs/node/pull/62254 Reviewed-By: Anna Henningsen <anna@addaleax.net> ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/62254 Reviewed-By: Anna Henningsen <anna@addaleax.net> -------------------------------------------------------------------------------- โน This PR was created on Sat, 14 Mar 2026 16:27:50 GMT โ Approvals: 1 โ - Anna Henningsen (@addaleax): https://github.com/nodejs/node/pull/62254#pullrequestreview-3950716542 โ Last GitHub CI successful โน Last Full PR CI on 2026-03-18T17:02:27Z: https://ci.nodejs.org/job/node-test-pull-request/71864/ - Querying data for job/node-test-pull-request/71864/ โ Last Jenkins CI successful -------------------------------------------------------------------------------- โ No git cherry-pick in progress โ No git am in progress โ No git rebase in progress -------------------------------------------------------------------------------- - Bringing origin/main up to date... From https://github.com/nodejs/node * branch main -> FETCH_HEAD โ origin/main is now up-to-date - Downloading patch for 62254 From https://github.com/nodejs/node * branch refs/pull/62254/merge -> FETCH_HEAD โ Fetched commits as 22fc52bda16b..e37890620fa3 -------------------------------------------------------------------------------- [main ea4524b511] crypto: add crypto::GetSSLCtx API for addon access to OpenSSL contexts Author: Tim Perry <pimterry@gmail.com> Date: Sat Mar 14 16:09:37 2026 +0100 6 files changed, 159 insertions(+) create mode 100644 test/addons/openssl-get-ssl-ctx/binding.cc create mode 100644 test/addons/openssl-get-ssl-ctx/binding.gyp create mode 100644 test/addons/openssl-get-ssl-ctx/test.js [main a8907b2aca] Handle JS getter exceptions in GetSSLCtx Author: Tim Perry <pimterry@gmail.com> Date: Sun Mar 15 18:15:20 2026 +0100 2 files changed, 12 insertions(+) โ Patches applied There are 2 commits in the PR. Attempting to fixup everything into first commit. [main 55124ce18f] crypto: add crypto::GetSSLCtx API for addon access to OpenSSL contexts Author: Tim Perry <pimterry@gmail.com> Date: Sat Mar 14 16:09:37 2026 +0100 6 files changed, 171 insertions(+) create mode 100644 test/addons/openssl-get-ssl-ctx/binding.cc create mode 100644 test/addons/openssl-get-ssl-ctx/binding.gyp create mode 100644 test/addons/openssl-get-ssl-ctx/test.js --------------------------------- New Message ---------------------------------- crypto: add crypto::GetSSLCtx API for addon access to OpenSSL contexts
Temporary files removed.
|
Once upon a time (#20237) we attempted to remove the
secureContext.context._externalfield which exposes OpenSSL contexts. This was later reverted (#21711) because it turns out there are external native addons which do want to integrate with Node's OpenSSL, and were using this JS API as it's currently the only way to do so.At the time, @sam-github said:
I think this makes a lot of sense. I'm in the process of building a native addon myself that needs access to OpenSSL contexts (user-space solution for #41112). I'd like to do this properly, without having to awkwardly hook onto internals like this.
This PR does that: creating a new
node::crypto::GetSSLCtxnative API, so C++ addons can access the OpenSSL context directly. With this in place, we could potentially drop_externalentirely from the JS API (and maybe even.context) in some future major bump. Naming is intended to match the SSL_CTX type and OpenSSL SSL_CTX_... APIs etc, but open to bikeshedding that further.This API itself should be easy to keep stable as OpenSSL changes, but obviously SSL_CTX won't be stable as it has APIs that will change as we upgrade OpenSSL versions etc. I think that's fine, there's clearly no real avoiding that and addons using this will have to be able to deal with OpenSSL changes like this appropriately. Reasonable given that it's a native-only API imo.