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

importX509 certificates with missing version number #308

Closed
2 tasks done
mikedh opened this issue Nov 5, 2021 · 3 comments
Closed
2 tasks done

importX509 certificates with missing version number #308

mikedh opened this issue Nov 5, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@mikedh
Copy link

mikedh commented Nov 5, 2021

What happened?

Hi, thanks for the great library!

I generated x509 format certificates using the ED25519 algorithm with openssl from the instructions here. I've been reliably getting this error when I call importX509 (I tried as far as I can tell every combination of import... and alg):

mikedh@luna:sandbox$ node key_issue.js 
(node:599349) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'raw' of undefined
    at spkiFromX509 (/home/mikedh/sandbox/node_modules/jose/dist/node/cjs/key/import.js:68:110)
    at getSPKI (/home/mikedh/sandbox/node_modules/jose/dist/node/cjs/key/import.js:73:41)
    at importX509 (/home/mikedh/sandbox/node_modules/jose/dist/node/cjs/key/import.js:86:18)
    at Object.<anonymous> (/home/mikedh/sandbox/key_issue.js:3:13)

I'm not sure if this is me trying to import an incorrect certificate or a bug with importX509. For what it's worth, openssl can read back the certificates and seems happy. The script I used to call openssl to generate the minimal example below and full console output are in this gist.

Version

4.1.4

Runtime

Node.js

Runtime Details

Node v12.21.1

Code to reproduce

const { importX509 } = require('jose')
const ed25519 = {"publicKey": "-----BEGIN CERTIFICATE-----\nMIIB0zCCAYUCFEAGUxyTR1mz/XyaVnqHUA1T0bg4MAUGAytlcDCBizELMAkGA1UE\nBhMCVVMxFTATBgNVBAgMDFBlbm5zeWx2YW5pYTETMBEGA1UEBwwKUGl0dHNidXJn\naDEWMBQGA1UECgwNRXhhbXBsZSwgSW5jLjEiMCAGCSqGSIb3DQEJARYTZXhhbXBs\nZUBleGFtcGxlLmNvbTEUMBIGA1UEAwwLZXhhbXBsZS5jb20wHhcNMjExMTA1MTkz\nNTQ4WhcNMjMxMDA2MTkzNTQ4WjCBizELMAkGA1UEBhMCVVMxFTATBgNVBAgMDFBl\nbm5zeWx2YW5pYTETMBEGA1UEBwwKUGl0dHNidXJnaDEWMBQGA1UECgwNRXhhbXBs\nZSwgSW5jLjEiMCAGCSqGSIb3DQEJARYTZXhhbXBsZUBleGFtcGxlLmNvbTEUMBIG\nA1UEAwwLZXhhbXBsZS5jb20wKjAFBgMrZXADIQCuVl9VNLFAflCTZDKRtWjGLqsD\ne/E5r+zIN1H6rWkE/DAFBgMrZXADQQDet6id3ZIBqQ4RP1GBRHN19epkb7euezw6\nYlmU09Tsz1j7utsNgs6ztF43GyzzVWrBtHkjne7qtnIONDqSvJoC\n-----END CERTIFICATE-----\n", "privateKey": "-----BEGIN PRIVATE KEY-----\nMC4CAQAwBQYDK2VwBCIEICXB7D1ntExZMLLyAIQJLP42umn571JT9igQM9wYXkT9\n-----END PRIVATE KEY-----\n", "csr": "-----BEGIN CERTIFICATE REQUEST-----\nMIIBDDCBvwIBADCBizELMAkGA1UEBhMCVVMxFTATBgNVBAgMDFBlbm5zeWx2YW5p\nYTETMBEGA1UEBwwKUGl0dHNidXJnaDEWMBQGA1UECgwNRXhhbXBsZSwgSW5jLjEi\nMCAGCSqGSIb3DQEJARYTZXhhbXBsZUBleGFtcGxlLmNvbTEUMBIGA1UEAwwLZXhh\nbXBsZS5jb20wKjAFBgMrZXADIQCuVl9VNLFAflCTZDKRtWjGLqsDe/E5r+zIN1H6\nrWkE/KAAMAUGAytlcANBADSUCTmispUEssUoE2LLG3DGeAWSQAVMBhomBzxVURwg\nYa0Uhnlr7No7ZeRpKm2mAVSAt151L9XSYWV8NNbVrwo=\n-----END CERTIFICATE REQUEST-----\n"}
const key = importX509(ed25519.publicKey, 'EdDSA')

  • I have searched the issues tracker and discussions for similar topics and couldn't find anything related.
  • I agree to follow this project's Code of Conduct
@mikedh mikedh added the triage label Nov 5, 2021
@panva panva changed the title ED25519 X509 Certificates From Openssl importX509 certificates with missing version number Nov 5, 2021
@panva panva added bug Something isn't working and removed triage labels Nov 5, 2021
@panva
Copy link
Owner

panva commented Nov 5, 2021

Hi @mikedh. Thank you for bringing it up. I kinda knew about this but wasn't counting on certificates without a version number to come up. Guess i was wrong. The latest release has this issue fixed.

@mikedh
Copy link
Author

mikedh commented Nov 5, 2021

Awesome thanks for the fix!!

@mikedh
Copy link
Author

mikedh commented Nov 5, 2021

Confirmed working on the latest version on NPM. Thanks again!

@github-actions github-actions bot locked and limited conversation to collaborators Feb 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants