minghua
minghua

Reputation: 6581

Python Usable X509 ASN.1 File for asn1tools

I'd like to print all x509 information from a certificate. Here's what have been done:

It's spiting out an error:

    File ".../test-print-ssl.py", line 47, in cert_print_asn1
        output = foo.decode("Certificate", cert)
      File "...\lib\site-packages\asn1tools\compiler.py", line 161, in decode
        "Type '{}' not found in types dictionary.".format(name))
    asn1tools.errors.DecodeError: Type 'Certificate' not found in types dictionary.

A few questions:

Note that I've used command openssl x509 -in website.com.pem -text to print the same cert from file. That works. I guess I can invoke using os.system() to achieve the same. I'd like to have a solution to decode and print in python.

I've seen the question that failing compilation, but in my case it is failing decoding, that is different.

Upvotes: 0

Views: 786

Answers (1)

YaFred
YaFred

Reputation: 10008

You should share your files to allow more specific answers ....

You can just create one file concatenating the types from your files.

Instead of throwing everything in one go, you should only put the type(s) you need and add what is missing.

The content of your asn1 specification should be something like

X509 DEFINITIONS ::= 
BEGIN

Type1

Type2

END

You can validate your file on https://asn1.io/asn1playground/

Upvotes: 1

Related Questions