Search code examples
javascriptcertificatex509certificatex509certificate2der

How do I convert DER Format certificate x509 into human readable format?


How can I convert a DER Format certificate x509 into a human readable format in JavaScript?


Solution

  • Javascript does not provide a method to parse certificate fields. You need to use a library like forge. I think you need something like this

    var certAsn1 = forge.asn1.fromDer(certDer)
    var cert = forge.pki.certificateFromAsn1(certAsn1);
    console.log(cert.serialNumber);