From e64b6b5fe36aeef46b5538a7d301dbc715e4c6c1 Mon Sep 17 00:00:00 2001 From: "patrick.pdb" Date: Tue, 14 Nov 2023 20:03:27 -0300 Subject: [PATCH] '#1978 Adding some more metadata extraction. --- .../parsers/security/CertificateParser.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/iped-parsers/iped-parsers-impl/src/main/java/iped/parsers/security/CertificateParser.java b/iped-parsers/iped-parsers-impl/src/main/java/iped/parsers/security/CertificateParser.java index 9d684db4b7..a569d0b1f0 100644 --- a/iped-parsers/iped-parsers-impl/src/main/java/iped/parsers/security/CertificateParser.java +++ b/iped-parsers/iped-parsers-impl/src/main/java/iped/parsers/security/CertificateParser.java @@ -68,9 +68,12 @@ public class CertificateParser extends AbstractParser { public static final Property NOTBEFORE = Property.internalDate("certificate:notBefore"); //$NON-NLS-1$ public static final Property NOTAFTER = Property.internalDate("certificate:notAfter"); //$NON-NLS-1$ public static final String ISSUER = "certificate:issuer"; //$NON-NLS-1$ + private static final String X500_ISSUER = "certificate:X500Issuer"; public static final String SUBJECT = "certificate:subject"; //$NON-NLS-1$ + public static final String X500_SUBJECT = "certificate:X500Subject"; //$NON-NLS-1$ public static final Property ISSUBJECTAUTHORITY = Property.internalBoolean("certificate:subjectIsCertAuthority"); //$NON-NLS-1$ public static final String NOALTNAMES = "This certificate has no alternative names."; + public CertificateParser() { MetadataUtil.setMetadataType(NOTBEFORE.getName(), Date.class); @@ -147,8 +150,11 @@ public void parse(InputStream stream, ContentHandler handler, Metadata metadata, metadata.set(NOTBEFORE, cert.getNotBefore()); metadata.set(NOTAFTER, cert.getNotAfter()); - metadata.set(ISSUER, cert.getIssuerX500Principal().getName()); - metadata.set(SUBJECT, cert.getSubjectX500Principal().getName()); + + metadata.set(X500_ISSUER, cert.getIssuerX500Principal().getName()); + metadata.set(ISSUER, cert.getIssuerDN().getName()); + metadata.set(X500_SUBJECT, cert.getSubjectX500Principal().getName()); + metadata.set(SUBJECT, cert.getSubjectDN().getName()); if (cert.getBasicConstraints() <= -1) { metadata.set(ISSUBJECTAUTHORITY, Boolean.FALSE.toString()); } else { @@ -189,6 +195,15 @@ private void generateCertificateHtml(X509Certificate cert, XHTMLContentHandler x xhtml.endElement("td"); xhtml.endElement("tr"); + xhtml.startElement("tr"); + xhtml.startElement("td"); + xhtml.characters("Subject"); + xhtml.endElement("td"); + xhtml.startElement("td"); + xhtml.characters(cert.getSubjectDN().getName()); + xhtml.endElement("td"); + xhtml.endElement("tr"); + xhtml.startElement("tr"); xhtml.startElement("td"); xhtml.characters("Version");