Skip to content
Snippets Groups Projects
signingUtilities.js 34.7 KiB
Newer Older
  • Learn to ignore specific revisions
  •         const subjVal = typeAndValue.value.valueBlock.value;
            certificateData.subject[typeVal] = subjVal;
          }
    
          certificateData.signatureAlgorithm = signatureAlgorithm;
          certificateData.serialNumber = serialNumber;
          certificateData.validity = {
            notAfter,
            notBefore
          };
    
          return certificateData;
        });
      } catch (e) {
        console.error("Error parsing certificate", e);
      }
    };
    
    export const getCertificateChain = signatureBase64 => {
      const certificateChain = [];
    
      try {
        const certificates = parseCertificates(signatureBase64);
    
        // Add first certificate in the chain
        certificateChain.push(certificates[0]);
    
        // Go through all certificates to build a chain from first certificate to the root
        certificates.forEach(certificate => {
          if (certificateChain[0].issuer.commonName === certificate.subject.commonName) {
            certificateChain.unshift(certificate);
          }
        });
      } catch (e) {
        console.warn("Error getting certificate data", e);
      }
    
      return certificateChain;
    };