Skip to content

Forge accept a certificate with version 1 and extension fields #1145

Description

@Jennifer-first

I have a certificate chain [rootCA,intermediate certificate,leaf certificate], where the leaf certificate has an extended field with a version number of 1. This leaf certificate violates RFC5280 Section 4.1.2.1: "When using extended fields (as expected in this specification), the version number must be 3 (currently 2)." However, this certificate chain still passes Forge's certificate verification.

To Reproduce:

const { pki } = require('node-forge');
const { readFileSync } = require('fs');
const [, , caPath, certPath] = process.argv;
const caStore = pki.createCaStore([pki.certificateFromPem(readFileSync(caPath, 'utf8'))]);
const serverCert = pki.certificateFromPem(readFileSync(certPath, 'utf8'));
console.log(pki.verifyCertificateChain(caStore, [serverCert]));

node verify.js ca.pem seed.pem

Expected behavior:
Verification failed.

test.zip

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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