Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support parsing x509 certificate with ECC public key #791

Open
martinraie opened this issue Jun 19, 2020 · 2 comments
Open

Support parsing x509 certificate with ECC public key #791

martinraie opened this issue Jun 19, 2020 · 2 comments

Comments

@martinraie
Copy link

Parsing x509 certificate with ECC public key fails with error Cannot read public key. Unknown OID. In our case we only need subject and validity data from certificate which is the same for both RSA and ECC cases. If Forge parses x509 with unsupported keys, it could just leave the key information blank instead of throwing and exception.

I'm not too familiar with Forge source code but I tested the following simple change which worked for our case:
Remove following lines from certificateFromAsn1 function (rows 1288:1290 in x509.js):

  if(oid !== pki.oids.rsaEncryption) {
    throw new Error('Cannot read public key. OID is not RSA.');
  }

Wrap last lines of the same function inside if-block:

  if(oid === pki.oids.rsaEncryption) {
    // convert RSA public key from ASN.1
    cert.publicKey = pki.publicKeyFromAsn1(capture.subjectPublicKeyInfo);
  }

Would this change be acceptable or is there any specific reason why certificateFromAsn1 function should throw exception instead of leaving publicKey field blank?

@dlongley
Copy link
Member

This seems like a reasonable approach until a public key parser for ECC can be added.

@hamano
Copy link

hamano commented Nov 22, 2021

I did it:
#925

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants