-
Notifications
You must be signed in to change notification settings - Fork 15
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
Example for validating a certificate chain #24
Comments
Current version doesn't check certificate revocations. You can use current API for path building. And check by yourself that the last cert in chain is trusted const chain = new x509.X509ChainBuilder({
certificates: certs,
});
const items = await chain.build(cert); We are going to extend current API for chain validation described in RFC5280 |
Could use some better examples of this, ideally a simple 2 layer example. |
Exampleimport * as x509 from "@peculiar/x509";
// Read certificates
const rootCert = new x509.X509Certificate(rootRaw);
const ca1Cert = new x509.X509Certificate(ca1Raw);
const ca2Cert = new x509.X509Certificate(ca2Raw);
const ca3Cert = new x509.X509Certificate(ca3Raw);
// ...
const leafCert = new x509.X509Certificate(leafRaw);
// Build chain
const certificates = [ca3Cert, ca2Cert, ca1Cert, /* ... */, rootCert];
const chain = new x509.X509ChainBuilder({
certificates,
});
const items = await chain.build(leafCert);
// Print chain
for (const cert of items) {
console.log(cert.subject);
}
console.log(items.toString("pem-chain")); Output
|
Thank you! I was able to figure it out after I left this comment, but your code is probably better for future readers than mine would have been. I suggest closing this issue. |
I would like to check whether a given x.509 certificate has been signed by a known root certificate (CA). Can this library be used for that?
The text was updated successfully, but these errors were encountered: