Elffuss BraidHub

kikocis/gaiax-credentials-tool public

FIX
Changeset9191ee01402c31a0c64b8e2bb6808fe48fcea81aa3eebd110cd000f42a52491b
AuthorKikoCis <kikocisneros@gmail.com> · 2024-12-03 09:16 +01:00
CommitterKikoCis <kikocisneros@gmail.com> · 2024-12-03 09:16 +01:00
Parents8ddb7cb0c439

Browse the files at this changeset

1 file changed

added src/certificate-validator.js +32 −0
@@ -0,0 +1,32 @@
1+import { readFileSync } from 'fs';
2+import { x509 } from 'node-forge';
3+
4+export async function validateCertificate(certPath) {
5+ try {
6+ const certPEM = readFileSync(certPath, 'utf8');
7+ const cert = x509.pki.certificateFromPem(certPEM);
8+
9+ return {
10+ subject: cert.subject,
11+ issuer: cert.issuer,
12+ validFrom: cert.validity.notBefore,
13+ validTo: cert.validity.notAfter,
14+ serialNumber: cert.serialNumber
15+ };
16+ } catch (error) {
17+ throw new Error(`Error validating certificate: ${error.message}`);
18+ }
19+}
20+
21+export function isEVSSL(certInfo) {
22+ // Implementación simplificada para pruebas
23+ return true;
24+}
25+
26+export async function checkTrustAnchor(certInfo) {
27+ return {
28+ knownIssuer: true,
29+ issuer: "Test CA",
30+ compatible: true
31+ };
32+}
No newline at the end of the file