Repository navigation
Conversation
Expose callback-based generateX509Certificate() and synchronous generateX509CertificateSync(), producing X509Certificate objects for self-signed and issuer-signed X.509 v3 certificates. Accept grouped distinguished names or exact subject DER, public keys, serial numbers, validity dates, and an explicit signing digest. Reuse crypto.sign() key inputs and RSA options, including OpenSSL STORE-backed keys. A PKCS#10 request can supply the subject and public key instead. Require a synchronous selectExtensions callback to accept, replace, or amend the requested extensions. Verify the request signature before signing the certificate, in the selected sync or async mode. Provide typed Basic Constraints, Key Usage, Extended Key Usage, SAN, SKI, and AKI, plus arbitrary raw extensions. Add none implicitly and leave raw extension semantics to the caller. Copy mutable inputs before queueing asynchronous work. Certificate trust and CA authorization remain the caller's responsibility. Fixes: nodejs#51169 Assisted-by: Codex Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Require a supported backend when selecting the BIT STRING length capability. Reject other backends at compile time, matching the surrounding checks used to catch unsupported OpenSSL backports. Assisted-by: Codex Signed-off-by: Filip Skokan <panva.ip@gmail.com>
|
Review requested:
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #67245 +/- ##
==========================================
- Coverage 90.68% 90.63% -0.06%
==========================================
Files 797 800 +3
Lines 279367 280794 +1427
Branches 53737 54083 +346
==========================================
+ Hits 253344 254493 +1149
- Misses 16319 16443 +124
- Partials 9704 9858 +154
🚀 New features to boost your workflow:
|
|
Landed in 77e6379...2336a1f |
Expose callback-based generateX509Certificate() and synchronous generateX509CertificateSync(), producing X509Certificate objects for self-signed and issuer-signed X.509 v3 certificates. Accept grouped distinguished names or exact subject DER, public keys, serial numbers, validity dates, and an explicit signing digest. Reuse crypto.sign() key inputs and RSA options, including OpenSSL STORE-backed keys. A PKCS#10 request can supply the subject and public key instead. Require a synchronous selectExtensions callback to accept, replace, or amend the requested extensions. Verify the request signature before signing the certificate, in the selected sync or async mode. Provide typed Basic Constraints, Key Usage, Extended Key Usage, SAN, SKI, and AKI, plus arbitrary raw extensions. Add none implicitly and leave raw extension semantics to the caller. Copy mutable inputs before queueing asynchronous work. Certificate trust and CA authorization remain the caller's responsibility. Fixes: #51169 Assisted-by: Codex Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: #67245 Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Require a supported backend when selecting the BIT STRING length capability. Reject other backends at compile time, matching the surrounding checks used to catch unsupported OpenSSL backports. Assisted-by: Codex Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: #67245 Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Expose callback-based generateX509Certificate() and synchronous generateX509CertificateSync(), producing X509Certificate objects for self-signed and issuer-signed X.509 v3 certificates. Accept grouped distinguished names or exact subject DER, public keys, serial numbers, validity dates, and an explicit signing digest. Reuse crypto.sign() key inputs and RSA options, including OpenSSL STORE-backed keys. A PKCS#10 request can supply the subject and public key instead. Require a synchronous selectExtensions callback to accept, replace, or amend the requested extensions. Verify the request signature before signing the certificate, in the selected sync or async mode. Provide typed Basic Constraints, Key Usage, Extended Key Usage, SAN, SKI, and AKI, plus arbitrary raw extensions. Add none implicitly and leave raw extension semantics to the caller. Copy mutable inputs before queueing asynchronous work. Certificate trust and CA authorization remain the caller's responsibility. Fixes: #51169 Assisted-by: Codex Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: #67245 Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Require a supported backend when selecting the BIT STRING length capability. Reject other backends at compile time, matching the surrounding checks used to catch unsupported OpenSSL backports. Assisted-by: Codex Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: #67245 Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Notable changes: child_process: * (SEMVER-MINOR) add subprocess.timedOut (Marco) #66639 crypto: * (SEMVER-MINOR) make X.509 inspection guards explicit (Filip Skokan) #67245 * (SEMVER-MINOR) add X.509 generation with CSR support (Filip Skokan) #67245 dns: * (SEMVER-MINOR) coalesce identical concurrent lookup() requests (Orgad Shaneh) #62599 doc: * add efekrskl to collaborators (Efe Karasakal) #67376 * add Philipp Dunkel to contributors (Philipp Dunkel) #67378 * add christianaurichzm to collaborators (Christian Aurich Zanettini Martins) #67377 http: * (SEMVER-MINOR) batch body spans per parser execute (Guilherme Araújo) #67187 sea: * (SEMVER-MINOR) generate a compile cache for the VFS modules (Matteo Collina) #66768 worker: * (SEMVER-MINOR) preload streams into startup snapshot (Matteo Collina) #66311 PR-URL: #67415
Notable changes: child_process: * (SEMVER-MINOR) add subprocess.timedOut (Marco) #66639 crypto: * (SEMVER-MINOR) make X.509 inspection guards explicit (Filip Skokan) #67245 * (SEMVER-MINOR) add X.509 generation with CSR support (Filip Skokan) #67245 dns: * (SEMVER-MINOR) coalesce identical concurrent lookup() requests (Orgad Shaneh) #62599 doc: * add efekrskl to collaborators (Efe Karasakal) #67376 * add Philipp Dunkel to contributors (Philipp Dunkel) #67378 * add christianaurichzm to collaborators (Christian Aurich Zanettini Martins) #67377 http: * (SEMVER-MINOR) batch body spans per parser execute (Guilherme Araújo) #67187 sea: * (SEMVER-MINOR) generate a compile cache for the VFS modules (Matteo Collina) #66768 worker: * (SEMVER-MINOR) preload streams into startup snapshot (Matteo Collina) #66311 PR-URL: #67415
|
I has taken me millennia, but sorry @panva, but I've now had a change to properly look at this and play with it. I've built out a local version of my setup on top to test it in practice, and it does work nicely! Speeds up my cert generation code up to 6x, which is very nice indeed 😃 There are some non-breaking additions which would simplify using it in my setup (we'll get to those later) but excluding that, some other bits worth mentioning here in the meantime: I found a few small specific tiny issues, which I've opened quick fixes to cover in #67781. I think the CSR API design could be improved. I think it falls in an unhappy valley right now: it's a specialized feature that most users won't need, but for the users who do need it it's too limited. I'm particularly thinking about the If we consider that the current CSR flow looks roughly like this: generateX509CertificateSync({
csr, issuer, serialNumber, notBefore, notAfter, signature,
selectExtensions(requestedExts) { return applyPolicy(requestedExts); }
});I wonder if it should look more like: const req = X509CertificateRequest.parse(csr);
doCustomValidation(req); // Read any field, do anything
generateX509Certificate({
subject: req.subjectName.raw,
publicKey: req.publicKey,
extensions: await applyCustomExtensionPolicy(req),
...
});That shape has the advantage of making cert generation completely independent of CSRs, instead of mixing the CSR code into cert generation. They can be separate implementations that users glue together themselves. Makes it much easier to apply policy & transformations freely, and makes both implementations simpler. Separately: even without that change, I think we might want to consider moving the CSR part of this API back to stage 1.1 experimental, behind a CLI flag, because it's security sensitive. CSRs mean feeding parsing of attacker input into trusted cert generation. I don't see any obvious issues today, but I bet a wave of AI scanners will find some soon enough. It will be much easier to find & fix those bugs in public while this is fully experimental, instead of having to treat all issues as serious vulnerabilities that we have to fix in secret. Only applies to CSRs specifically since they're generally external input. I think most other X509 generation (barring extremely horrible bugs) wouldn't be security issues, the most likely failure cases just result in broken certs I think. Passing untrusted input into a X509 generation APIs is a bug in your code, not ours. I have some other notable thoughts on the TBS side, which we briefly discussed in Slack, I still need to dig into that and explore it. I think there's some tiny API changes here that would make that easier to glue together, but nothing major. Otherwise everything looks great to me. Thanks for all the work on this @panva! |
Expose callback-based
generateX509Certificate()and synchronousgenerateX509CertificateSync(), producingX509Certificateobjects for self-signed and issuer-signed X.509 v3 certificates. Accept grouped distinguished names or exact subject DER, public keys, serial numbers, validity dates, and an explicit signing digest. Reusecrypto.sign()key inputs and RSA options, including OpenSSL STORE-backed keys.A PKCS#10 request can supply the subject and public key instead. Require a synchronous
selectExtensionscallback to accept, replace, or amend the requested extensions. Verify the request signature before signing the certificate, in the selected sync or async mode.Provide typed Basic Constraints, Key Usage, Extended Key Usage, SAN, SKI, and AKI, plus arbitrary raw extensions. Add none implicitly and leave raw extension semantics to the caller. Copy mutable inputs before queueing asynchronous work. Certificate trust and CA authorization remain the caller's responsibility.
This is PR 4 out of 4 in an X.509 series addressing #48730 and #51169.