Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to extract raw hex ASN.1 data from X.509 certificate. I know, that I can do this by using DER format and hexdumping it.

I'm interested in particular parts like "subject", "issuer" and their raw hex ASN1 data.

share|improve this question

Determine offset of interesting part by using (number in first column):

openssl x509 -in crt.pem -outform der | openssl asn1parse -inform der -i

For example, if "subject" entry is at offset 119. Dump raw data of that substructure:

openssl x509 -in crt.pem -outform der | openssl asn1parse -inform der -i -strparse 119 -noout -out subject.raw

Now print raw hex data:

cat subject.raw | od --address-radix=n --format=x1 | tr -d ' \n'

share|improve this answer
for portability: long options in od command could be replaced by short variants -tx1 -An (see man page). – mighq May 14 '15 at 7:50

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.