From e21140ce58d2dc4cc6b6515f9e73c3ac7123481d Mon Sep 17 00:00:00 2001 From: Bsian Date: Wed, 1 Jan 2020 13:19:31 +0000 Subject: [PATCH] Fix array errors if null --- src/functions/parseCertificate.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/functions/parseCertificate.ts b/src/functions/parseCertificate.ts index 2f45301..f9d78ca 100644 --- a/src/functions/parseCertificate.ts +++ b/src/functions/parseCertificate.ts @@ -35,16 +35,16 @@ export default async function parseCertificate(client: Client, pathToCertificate subject: { commonName: parsedObject.RawParse.Subject.CommonName, emailAddress: parsedObject.AbstractParse.EmailAddress, - organizationName: parsedObject.RawParse.Subject.Organization[0], - organizationalUnitName: parsedObject.RawParse.Subject.OrganizationalUnit[0], - countryName: parsedObject.RawParse.Subject.Country[0], + organizationName: parsedObject.RawParse.Subject.Organization ? parsedObject.RawParse.Subject.Organization[0] : null, + organizationalUnitName: parsedObject.RawParse.Subject.OrganizationalUnit ? parsedObject.RawParse.Subject.OrganizationalUnit[0] : null, + countryName: parsedObject.RawParse.Subject.Country ? parsedObject.RawParse.Subject.Country[0] : null, }, issuer: { commonName: parsedObject.RawParse.Issuer.CommonName, emailAddress: null, - organizationName: parsedObject.RawParse.Issuer.Organization[0], - organizationalUnitName: parsedObject.RawParse.Issuer.OrganizationalUnit[0], - countryName: parsedObject.RawParse.Issuer.Country[0], + organizationName: parsedObject.RawParse.Issuer.Organization ? parsedObject.RawParse.Issuer.Organization[0] : null, + organizationalUnitName: parsedObject.RawParse.Issuer.OrganizationalUnit ? parsedObject.RawParse.Issuer.OrganizationalUnit[0] : null, + countryName: parsedObject.RawParse.Issuer.Country ? parsedObject.RawParse.Issuer.Country[0] : null, }, extensions: { keyUsage: '[ Not implemented by executable ]',