Inspect any structure with this ASN.1 decoder
Certificates, CSRs, private keys, PKCS#7 bundles, timestamps and many smart-card formats are all ASN.1 data encoded with DER or BER. This ASN.1 decoder parses those bytes and prints them as an indented tree, so you can see exactly what a file contains even when no specialized tool understands it. It shows the same kind of view as openssl asn1parse -i, with object identifiers translated to names.
What is ASN.1?
ASN.1 (Abstract Syntax Notation One) is a language for describing data structures. DER and BER are the binary encodings of those structures. Every element is a TLV: a tag saying what it is (SEQUENCE, INTEGER, OBJECT IDENTIFIER…), a length, and the value. Constructed elements such as SEQUENCE and SET contain other elements, which produces the tree you see in the output. PEM is simply DER wrapped in Base64 with BEGIN and END lines.
Example
The first lines of a decoded X.509 certificate:
# CERTIFICATE (639 bytes)
SEQUENCE (3 elem)
SEQUENCE (8 elem)
[0] (1 elem)
INTEGER 2
INTEGER (160 bit) 0a0260412a723b0e74659ffd7f9008309d08d5d9
SEQUENCE (1 elem)
OBJECT IDENTIFIER 1.2.840.10045.4.3.2 ecdsa-with-SHA256
SEQUENCE (5 elem)
SET (1 elem)
SEQUENCE (2 elem)
OBJECT IDENTIFIER 2.5.4.6 countryName
PrintableString "US"
With Show byte offsets ticked, an EC public key looks like this:
0: SEQUENCE (2 elem)
2: SEQUENCE (2 elem)
4: OBJECT IDENTIFIER 1.2.840.10045.2.1 ecPublicKey
13: OBJECT IDENTIFIER 1.2.840.10045.3.1.7 prime256v1 (P-256)
23: BIT STRING (520 bit) 0426ba1c38c541decd2c443fdbe5e85162043f35…
How values are shown
- OBJECT IDENTIFIER: dotted form plus a name for common algorithms, attributes and extensions.
- INTEGER: small numbers in decimal. Large ones, like serial numbers and RSA moduli, show their bit length and hex digits.
- Strings: UTF8String, PrintableString, IA5String, BMPString and others are decoded to text in quotes.
- UTCTime and GeneralizedTime: converted to ISO 8601 dates.
- BIT STRING and OCTET STRING: when the content is itself valid DER, as with certificate extensions or a PKCS#8 private key, it is decoded in place and marked "encapsulates". Otherwise the hex is shown, shortened with "…" when long.
- Context tags: shown as
[0],[3]and so on. Their meaning depends on the surrounding structure.
BER indefinite-length encoding, used by some PKCS#7 and CMS files, is also parsed.
Common errors and fixes
- "Length … runs past the end of the data": the data is truncated, or it is not DER at all. Check that the whole PEM block or file was copied.
- "trailing byte(s) after the first element": the input holds extra data after one complete structure, such as two concatenated DER files.
- "This PEM block is encrypted": legacy encrypted keys (
Proc-Type: 4,ENCRYPTED) must be decrypted with openssl first. - Uploaded file fails to parse: PEM text files and binary DER files are both detected automatically, so a failure usually means the file is truncated or not ASN.1 at all (for example a ZIP archive or a Java .jks keystore).
- Hex not recognized: hex input is detected when it starts with
30, the SEQUENCE tag. Other hex strings are read as Base64, so convert them to PEM or Base64 first.
For a friendlier, field-by-field view of certificates and requests, use the certificate decoder or the CSR decoder. To turn PEM into raw bytes, try PEM to DER.
Privacy
Decoding is done by a small ASN.1 parser that runs in your browser. Files and pasted data are never uploaded, which matters when you are inspecting private keys.