crypto: support loading private keys through STORE loaders - #63949
Merged
Conversation
Collaborator
|
Review requested:
|
panva
force-pushed
the
keyobject-stores
branch
2 times, most recently
from
June 18, 2026 08:52
43f0d74 to
96c5081
Compare
panva
force-pushed
the
keyobject-stores
branch
2 times, most recently
from
June 18, 2026 09:03
ddd7eaf to
35bb771
Compare
jasnell
previously approved these changes
Jun 19, 2026
panva
dismissed
jasnell’s stale review
June 29, 2026 13:02
I changed the feature shape quite a bit. Dismissing a stale review.
jasnell
approved these changes
Jul 4, 2026
This comment was marked as resolved.
This comment was marked as resolved.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #63949 +/- ##
==========================================
- Coverage 90.30% 90.26% -0.04%
==========================================
Files 760 762 +2
Lines 247154 247425 +271
Branches 46613 46674 +61
==========================================
+ Hits 223181 223347 +166
- Misses 15443 15526 +83
- Partials 8530 8552 +22
🚀 New features to boost your workflow:
|
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as resolved.
This comment was marked as resolved.
3 tasks
Member
Author
|
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
Member
Author
|
Resolving conflict with d1f3d0a |
Accept WHATWG URL objects in private-key inputs and load referenced keys through OpenSSL STORE loaders. Pass optional property queries and passphrases while preserving provider-owned EVP_PKEY objects for ordinary KeyObject and CryptoKey operations. Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Contributor
Changelog@@ -694,0 +695 @@
+/nix/store/i8jyv4awyfkg1b065gcqcqpp27x7iyfm-libtasn1-4.21.0 (aarch64-darwin)
@@ -695,0 +697 @@
+/nix/store/rx1vh845iyrzg8s011jn3gx5m79ls7vq-libtasn1-4.21.0 (x86_64-darwin)
@@ -1000,0 +1003,4 @@
+/nix/store/wzl026xydz70snlvqalhyxi6ykvwqg75-node-pkcs11-softhsm (aarch64-darwin)
+/nix/store/7y5rw6fh5k7v29w80a200538b1m0416d-node-pkcs11-softhsm (aarch64-linux)
+/nix/store/ry1b8p26d8956b07fnyhdy1km1798fq2-node-pkcs11-softhsm (x86_64-darwin)
+/nix/store/4al1pqpw5l1wgd7vwjn0sfywj993gij9-node-pkcs11-softhsm (x86_64-linux)
@@ -1156,0 +1163,5 @@
+/nix/store/47x3k6bg2vawsrgynf65kxdlq1pr0kh7-openssl-pkcs11.cnf (aarch64-darwin)
+/nix/store/w3y21hx5dg2hnkch5lna79cz265fiphq-openssl-pkcs11.cnf (aarch64-linux)
+/nix/store/7sz3idgaqq1dpa1sc756c25lvh9hb9g1-openssl-pkcs11.cnf (x86_64-darwin)
+/nix/store/g6vlpipryrns8b11fmnn2mf4h3f63ahf-openssl-pkcs11.cnf (x86_64-linux)
+/nix/store/y8s864yb4binyfhzg198hnk38lshm3az-p11-kit-0.26.2 (aarch64-darwin)
@@ -1157,0 +1169 @@
+/nix/store/3m6nv9jvs114k0xpqnsqjmjyzv9643qf-p11-kit-0.26.2 (x86_64-darwin)
@@ -1345,0 +1358,4 @@
+/nix/store/ai6m8bm8w216jwicdym4ndlzbdc149nw-pkcs11-provider-1.2.0 (aarch64-darwin)
+/nix/store/77kxyyzmvkgm75g2dzxaccirn2pi148k-pkcs11-provider-1.2.0 (aarch64-linux)
+/nix/store/jb4w25b7dxwfy8fci52zgf8r9swb5mmb-pkcs11-provider-1.2.0 (x86_64-darwin)
+/nix/store/9w72flqh3gj158chgp9s8w65q587s69s-pkcs11-provider-1.2.0 (x86_64-linux)
@@ -1519,0 +1536,4 @@
+/nix/store/f39kdfrc185dij9nvvaqxzlx3vgzs181-softhsm-2.7.0 (aarch64-darwin)
+/nix/store/4w902rmqzd91j44kq8ql0r9m8fpmgfcs-softhsm-2.7.0 (aarch64-linux)
+/nix/store/8n7flys8x90kpz21lzjk76av2ipkngcp-softhsm-2.7.0 (x86_64-darwin)
+/nix/store/fiw0d9ikli4iy0vjsfpp3nd6qsxk01ay-softhsm-2.7.0 (x86_64-linux) |
Collaborator
jasnell
approved these changes
Aug 2, 2026
Collaborator
|
Landed in 565c3da |
aduh95
pushed a commit
that referenced
this pull request
Aug 3, 2026
Accept WHATWG URL objects in private-key inputs and load referenced keys through OpenSSL STORE loaders. Pass optional property queries and passphrases while preserving provider-owned EVP_PKEY objects for ordinary KeyObject and CryptoKey operations. Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: #63949 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
aduh95
pushed a commit
that referenced
this pull request
Aug 4, 2026
Accept WHATWG URL objects in private-key inputs and load referenced keys through OpenSSL STORE loaders. Pass optional property queries and passphrases while preserving provider-owned EVP_PKEY objects for ordinary KeyObject and CryptoKey operations. Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: #63949 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
aduh95
pushed a commit
that referenced
this pull request
Aug 4, 2026
Accept WHATWG URL objects in private-key inputs and load referenced keys through OpenSSL STORE loaders. Pass optional property queries and passphrases while preserving provider-owned EVP_PKEY objects for ordinary KeyObject and CryptoKey operations. Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: #63949 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
nodejs-github-bot
added a commit
that referenced
this pull request
Aug 4, 2026
Notable changes: build: * (SEMVER-MINOR) perfetto-sdk (Chengzhong Wu) #64565 crypto: * (SEMVER-MINOR) support loading private keys through STORE loaders (Filip Skokan) #63949 * update root certificates to NSS 3.125 (Node.js GitHub Bot) #64746 doc: * (SEMVER-MINOR) formalize fn/name as part of TestOptions API (Christopher Hiller) #64946 lib: * (SEMVER-MINOR) add perfetto support (Chengzhong Wu) #64565 module: * (SEMVER-MINOR) implement Symbol.dispose in ModuleHooks (Remco Haszing) #63928 net: * (SEMVER-MINOR) add experimental net/promises API (Ethan Arrowood) #63965 src: * (SEMVER-MINOR) add perfetto trace agent (Chengzhong Wu) #64565 * (SEMVER-MINOR) rename legacy trace event headers (Chengzhong Wu) #64565 * (SEMVER-MINOR) fix trace macro compatibility (Chengzhong Wu) #64565 test_runner: * (SEMVER-MINOR) add support for --test-coverage-include-all (avivkeller) #64830 PR-URL: #65027
aduh95
pushed a commit
that referenced
this pull request
Aug 4, 2026
Notable changes: crypto: * (SEMVER-MINOR) support loading private keys through STORE loaders (Filip Skokan) #63949 * update root certificates to NSS 3.125 (Node.js GitHub Bot) #64746 lib: * (SEMVER-MINOR) add perfetto support (Chengzhong Wu) #64565 module: * (SEMVER-MINOR) implement `Symbol.dispose` in ModuleHooks (Remco Haszing) #63928 net: * (SEMVER-MINOR) add experimental `node:net/promises` API (Ethan Arrowood) #63965 test_runner: * (SEMVER-MINOR) add support for `--test-coverage-include-all` (avivkeller) #64830 PR-URL: #65027
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.
Allow
crypto.createPrivateKey()and APIs that consume private keys, such ascrypto.sign(),crypto.privateDecrypt(),crypto.diffieHellman(), andcrypto.decapsulate(), to load private keys through configured OpenSSL STORE loaders using WHATWGURLobjects.This supports direct URL input:
It also supports object input with an optional passphrase or PIN and OpenSSL property query:
The provider implementing the STORE loader must already be loaded in Node.js' default OpenSSL library context, for example through OpenSSL configuration. This API does not load providers.
passphraseis forwarded to the loader as its passphrase or PIN.propertiesis an OpenSSL property query used to select the STORE loader; it is not appended to the URL and is distinct from provider-specific URI parameters.Why URL?
A
URLdistinguishes an external key reference from existing key material. Strings, buffers, typed arrays, and formatted objects retain their existing PEM, DER, JWK, and raw-key semantics. This avoids adding STORE loading to the key import/exportformatnamespace.URL input is accepted only in private-key contexts. A public key can be derived by first loading the private key and passing the resulting
KeyObjecttocrypto.createPublicKey().The resulting provider-backed key is an ordinary
KeyObjectand interoperates with existing private-key operations, key metadata, public-key derivation, andtoCryptoKey()where supported by the key algorithm and provider. Provider policy continues to control permitted operations and private-key exportability.The native STORE-loading path is available with OpenSSL >= 3.
Permission model
STORE loading adds the global
openssl.storepermission, enabled with--allow-openssl-storeand exposed through the runtime permission APIs:This permission grants broad authority to configured STORE loaders. Loaders may access files, devices, tokens, or the network, and that access is not constrained by the
fs.read,fs.write, ornetpermission scopes.This broad capability matches OpenSSL's behavior: STORE loaders perform their own I/O, and OpenSSL may try its file loader before another loader for opaque URIs.
When STORE access is denied, Node.js redacts the URI from the permission error resource and permission diagnostics.
Passphrases and errors
Credentials should be supplied through
passphraserather than embedded in the URI.If OpenSSL requests a passphrase and none was provided, Node.js throws
ERR_MISSING_PASSPHRASE, matching existing encrypted private-key import behavior. Incorrect passphrases and provider failures continue to surface as OpenSSL errors.Node.js redacts URIs from its own permission-denial errors. Errors reported by OpenSSL or a provider after loading begins may still include the URI.