The asn1crypto
package with x509 is being used. I'd like to find particular values in the .der file. The file is opened and read(), then:
mycert = x509.Certificate.load(data)
This returns an object of type asn1crypto.x509.Certificate
like so b'0\x81\x50\...'
. In debug, mycert
can be expanded to show the various keys and values, however I'd like to search directly in the 'mycert' for such keys/values. How can I do this?
EDIT:
The asn1crypto package doesn't have to be used, another one can be used instead.
EDIT:
Expanded code:
with open(cert_path, 'rb') as cert_file:
data = cert_file.read()
mycert = x509.Certificate.load(data)
a = mycert.native # doesn't work!
In
asn1crypto.x509
the attributenative
contains the native Python datatype representation of the certificate. The values are hierarchically structured and can be OrderedDicts as well:Output:
You can find several discussions in SO on how to search in a nested dict like "Find all occurrences of a key in nested dictionaries and lists".