build(deps-dev): bump @metcoder95/https-pem from 1.0.0 to 1.0.1 - #5800
Open
ViniciusDev26 wants to merge 1 commit into
Open
ViniciusDev26 wants to merge 1 commit into
ViniciusDev26 wants to merge 1 commit into
Conversation
metcoder95
reviewed
Sep 11, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5800 +/- ##
==========================================
- Coverage 93.52% 93.52% -0.01%
==========================================
Files 110 110
Lines 39415 39415
==========================================
- Hits 36864 36863 -1
- Misses 2551 2552 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Member
|
released new |
Fixes nodejs#5245. `selfsigned` builds the certificate serial number from 9 random bytes and runs them through its own `toPositiveHex()`, which clears the sign bit but does not re-minimise the resulting DER INTEGER. When those bytes start with 0x80 (or 0x00) followed by 0x00, the serial keeps two redundant leading zero bytes. node-forge strips only one of them -- the "should all leading bytes be stripped vs just one?" TODO in its asn1.js -- so a positive INTEGER with a leading 0x00 followed by a byte under 0x80 reaches OpenSSL, which rejects it with ERR_OSSL_ASN1_ILLEGAL_PADDING. It happens for roughly 1 in 65536 certificates, and `selfsigned`'s own `verifyCertificateChain()` does not catch it because node-forge's parser accepts the non-minimal encoding. The certificate only fails once OpenSSL reads it, so every test that builds a TLS/HTTP2 server from a freshly generated pair was flaky, most visibly test/http2-abort.js. The fix landed upstream in metcoder95/https-pem#2: the package now validates each certificate with X509Certificate and generates again when OpenSSL refuses it, for both the async generator and the pair written by the postinstall hook. Nothing is needed on undici's side beyond the bump.
ViniciusDev26
force-pushed
the
fix/flaky-pem-illegal-padding
branch
from
September 14, 2026 19:24
2e9b7ab to
00e1c24
Compare
Contributor
Author
sure, PR updated |
metcoder95
approved these changes
Sep 15, 2026
metcoder95
reviewed
Sep 15, 2026
metcoder95
left a comment
Member
There was a problem hiding this comment.
it seems like a single test is having troubles with it. Pool related one, if not mistaken recent change added
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.
Fixes #5245.
test/http2-abort.jswas not the problem.selfsignedoccasionally generates a certificate with a serial number OpenSSL cannot parse, so any test that builds a TLS server from a freshly generated pair can fail the same way.pem.generate()→@metcoder95/https-pem→selfsigned@3.0.1→node-forge@1.4.0. The serial comes fromselfsigned/index.js:That makes the integer positive, but it does not re-minimise it, and DER requires minimal encoding. When the 9 random bytes start with
0x80(or0x00) followed by0x00, the serial keeps two redundant leading zero bytes.node-forge would normally strip those, except it only strips one, and says so in
lib/asn1.js:So
00 00 01 …becomes00 01 …, still non-minimal. A positive INTEGER with a leading0x00followed by a byte under0x80is illegal padding, and OpenSSL rejects it:It takes two or more zero bytes followed by a byte under
0x80, which needsb0 ∈ {0x00, 0x80},b1 == 0x00andb2 < 0x80: roughly 1 in 65536 certificates.selfsignedrunsverifyCertificateChain()before returning and it passes, because node-forge's own parser accepts the non-minimal encoding, so the certificate only fails once OpenSSL reads it insidecreateSecureServer(). There is nothing platform-specific about it, so Windows andhttp2-abort.jsare just where it happened to land.What this changes
Per review, the fix was landed upstream rather than worked around here: metcoder95/https-pem#2, released as
@metcoder95/https-pem@1.0.1. The package now validates each generated certificate withX509Certificateand draws a new serial when OpenSSL refuses it, for both the async generator and the sync path used by the postinstall hook. Each attempt draws an independent serial, so three attempts make it a non-issue, and it throws rather than ever returning a broken pair.So this PR is now just the bump. No test file changes are needed.
The real fix still belongs in
selfsigned, emitting a minimally encoded serial:Finishing the node-forge TODO so it strips every redundant leading byte would fix the whole class of it, and the retry in https-pem can be dropped once that happens.