patching for edsca support since it is not in forge#206
Open
DonaldChung-HK wants to merge 2 commits into
Open
Conversation
garaimanoj
reviewed
Jul 14, 2026
|
|
||
| // 2. Intercept certificate parsing execution frames to handle missing OID validation | ||
| if (forge.pki.x509 && forge.pki.x509.signatureParameters) { | ||
| forge.pki.x509.signatureParameters['1.2.840.10045.4.3.3'] = { |
Contributor
There was a problem hiding this comment.
As we are using it multiple time, we can use
const OID = '1.2.840.10045.4.3.3';
const ecdsaSha384 = {
name: 'ecdsa-with-SHA384',
getMessageDigest: () => forge.md.sha384.create()
};
garaimanoj
reviewed
Jul 14, 2026
| }); | ||
| try { | ||
| const cert = originalFromAsn1.call(this, obj, false); | ||
| forge.pki.x509.signatureParameters = originalParams; |
Contributor
There was a problem hiding this comment.
We can use
finally { forge.pki.x509.signatureParameters = originalParams; }
garaimanoj
suggested changes
Jul 14, 2026
Contributor
Author
|
Updated. Thanks. |
Contributor
Author
|
Verified, correctly downloaded certificate from 3B and 2B |
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.
Description
This PR introduces a client-side polyfill to patch
node-forgein-memory on the certificate download page.The upcomming UK e-Science CA 3Bhas transitioned to signing certificates using
ecdsa-with-SHA384over thesecp384r1curve. Becausenode-forgenatively only supports RSA signature validation layouts for X.509 structures, the request download on CA portal portal was throwing a fatal runtime exception (Unknown signature OID: 1.2.840.10045.4.3.3) insidecertificateFromAsn1, blocking users from generating and downloading thei.p12bundles.The Fix
The injected script block hooks into the global
forgeinstance immediately after loading from the CDN and applies the following overrides:1.2.840.10045.4.3.3toecdsa-with-SHA384.forge.pki.certificateFromAsn1**to dynamically feed a mock message digest configuration frame whenever an unrecognized ECDSA signature validation check is triggered. This forces the parser to complete successfully without dropping key fields.NULLbefore signature: An ASN1diffrevealed that Forge's serialization layer was incorrectly appending aprim: NULLparameter to the ECDSA block during.p12packaging (a assumption valid for RSA since the key length need to be specified, but illegal under ECDSA specs like RFC 5758). The patch recursively filters the abstract syntax tree right before compilation to strip this explicitNULLpadding, ensuring that the downloaded certificate strictly matches the raw HSM bytes and successfully passes strict downstreamopenssl verifychecks.Security Evaluation
forge.pki.decryptRsaPrivateKey) and the strict public/private key modulus verification (privateKey.n !== cert.publicKey.n) remain unchanged and fully enforced in the browser memory. A user still cannot extract or compile a bundle without providing the legitimate password and matching private key file.Alternative
Ask user to paste the following Javascript block into console
Type of Change