Skip to content

CaStore fails if certificates use anything other than RSA #1119

@EmperorArthur

Description

@EmperorArthur

Issue

CaStore expects all certificates to use RSA. If this is not the case, as on some Windows machines, it breaks.

Code

Run this in the node interactive interpreter.

const { getCACertificates } = await import("tls");
const forge = require('node-forge');
const pki = forge.pki;
let caStore = pki.createCaStore(getCACertificates("system"));

Expected Behavior

caStore is successfully created.

Actual Behavior

Received the following Error:

Uncaught Error: Cannot read public key. OID is not RSA.
    at pki.certificateFromAsn1 (...\node_modules\node-forge\lib\x509.js:1316:11)
    at pki.certificateFromPem (...\node_modules\node-forge\lib\x509.js:822:14)
    at caStore.addCertificate (...\node_modules\node-forge\lib\x509.js:2694:24)
    at pki.createCaStore (...\node_modules\node-forge\lib\x509.js:2834:15)

Additional information

node --version

v22.16.0

systeminfo

OS Name: Microsoft Windows 10 Enterprise LTSC
OS Version: 10.0.19044 N/A Build 19044
OS Manufacturer: Microsoft Corporation
OS Configuration: Member Workstation
OS Build Type: Multiprocessor Free

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions