Viewing ASN.1 files content with GNUTLS' certtool RRS feed

  • General discussion

  • GnuTLS certificate tool, certtool, has an excellent capability of parsing ASN.1 structures. Wrapping it, here is a tiny 'lazy man' script aiming to get information about an ASN.1 encoded file, be it a public or private key, an X.509 certificate, a certificate revocation list, a PKCS #7 message, a PKCS #10 request, a PKCS #3 object, a PGP key ring, certificate, or key (both in PEM and DER formats). Simplicity of use was the only goal behind it.

    @echo off
    for %%a in (verbose inraw) do (
     for %%b in (certificate crl crq p12 p7 key pubkey pgp-key pgp-certificate pgp-ring dh) do (
      certtool --stdout-info --%%a --infile=%1 --%%b-info > nul 2> nul
      if not errorlevel 1 (
       certtool --stdout-info --%%a --infile=%1 --%%b-info --null-password
       exit /B 0
    @exit /B 1

    Best regards, 0x000000AF

    • Edited by 0x000000AF Friday, March 31, 2017 3:27 PM
    Sunday, December 25, 2016 4:45 PM