build(deps-dev): bump @metcoder95/https-pem from 1.0.0 to 1.0.1 - #5800
ViniciusDev26 wants to merge 1 commit into
Conversation
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:
|
|
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.
2e9b7ab to
00e1c24
Compare
sure, PR updated |
metcoder95
left a comment
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
Can you provide me with more details so I can investigate? Is there a dedicated issue for this case? |
|
I think that was fixed in #5828 |
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.