{
    "mode": "man",
    "parameter": "OPENSSL-ASN1PARSE",
    "section": "1SSL",
    "url": "https://www.chedong.com/phpMan.php/man/OPENSSL-ASN1PARSE/1SSL/json",
    "generated": "2026-06-15T18:53:26Z",
    "synopsis": "openssl asn1parse [-help] [-inform DER|PEM] [-in filename] [-out filename] [-noout] [-offset\nnumber] [-length number] [-i] [-oid filename] [-dump] [-dlimit num] [-strparse offset]\n[-genstr string] [-genconf file] [-strictpem] [-item name]",
    "sections": {
        "NAME": {
            "content": "openssl-asn1parse - ASN.1 parsing command\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "openssl asn1parse [-help] [-inform DER|PEM] [-in filename] [-out filename] [-noout] [-offset\nnumber] [-length number] [-i] [-oid filename] [-dump] [-dlimit num] [-strparse offset]\n[-genstr string] [-genconf file] [-strictpem] [-item name]\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This command is a diagnostic utility that can parse ASN.1 structures.  It can also be used to\nextract data from ASN.1 formatted data.\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "",
            "subsections": [
                {
                    "name": "-help",
                    "content": "Print out a usage message.\n"
                },
                {
                    "name": "-inform",
                    "content": "The input format; the default is PEM.  See openssl-format-options(1) for details.\n"
                },
                {
                    "name": "-in",
                    "content": "The input file, default is standard input.\n"
                },
                {
                    "name": "-out",
                    "content": "Output file to place the DER encoded data into. If this option is not present then no\ndata will be output. This is most useful when combined with the -strparse option.\n"
                },
                {
                    "name": "-noout",
                    "content": "Don't output the parsed version of the input file.\n"
                },
                {
                    "name": "-offset",
                    "content": "Starting offset to begin parsing, default is start of file.\n"
                },
                {
                    "name": "-length",
                    "content": "Number of bytes to parse, default is until end of file.\n"
                },
                {
                    "name": "-i",
                    "content": "",
                    "flag": "-i"
                },
                {
                    "name": "-oid",
                    "content": "A file containing additional OBJECT IDENTIFIERs (OIDs). The format of this file is\ndescribed in the NOTES section below.\n"
                },
                {
                    "name": "-dump",
                    "content": "Dump unknown data in hex format.\n"
                },
                {
                    "name": "-dlimit",
                    "content": "Like -dump, but only the first num bytes are output.\n"
                },
                {
                    "name": "-strparse",
                    "content": "Parse the contents octets of the ASN.1 object starting at offset. This option can be used\nmultiple times to \"drill down\" into a nested structure.\n"
                },
                {
                    "name": "-genstr -genconf",
                    "content": "Generate encoded data based on string, file or both using ASN1generatenconf(3) format.\nIf file only is present then the string is obtained from the default section using the\nname asn1. The encoded data is passed through the ASN1 parser and printed out as though\nit came from a file, the contents can thus be examined and written to a file using the\n-out option.\n"
                },
                {
                    "name": "-strictpem",
                    "content": "If this option is used then -inform will be ignored. Without this option any data in a\nPEM format input file will be treated as being base64 encoded and processed whether it\nhas the normal PEM BEGIN and END markers or not. This option will ignore any data prior\nto the start of the BEGIN marker, or after an END marker in a PEM file.\n"
                },
                {
                    "name": "-item",
                    "content": "Attempt to decode and print the data as an ASN1ITEM name. This can be used to print out\nthe fields of any supported ASN.1 structure if the type is known.\n"
                },
                {
                    "name": "Output",
                    "content": "The output will typically contain lines like this:\n\n0:d=0  hl=4 l= 681 cons: SEQUENCE\n\n.....\n\n229:d=3  hl=3 l= 141 prim: BIT STRING\n373:d=2  hl=3 l= 162 cons: cont [ 3 ]\n376:d=3  hl=3 l= 159 cons: SEQUENCE\n379:d=4  hl=2 l=  29 cons: SEQUENCE\n381:d=5  hl=2 l=   3 prim: OBJECT            :X509v3 Subject Key Identifier\n386:d=5  hl=2 l=  22 prim: OCTET STRING\n410:d=4  hl=2 l= 112 cons: SEQUENCE\n412:d=5  hl=2 l=   3 prim: OBJECT            :X509v3 Authority Key Identifier\n417:d=5  hl=2 l= 105 prim: OCTET STRING\n524:d=4  hl=2 l=  12 cons: SEQUENCE\n\n.....\n\nThis example is part of a self-signed certificate. Each line starts with the offset in\ndecimal. \"d=XX\" specifies the current depth. The depth is increased within the scope of any\nSET or SEQUENCE. \"hl=XX\" gives the header length (tag and length octets) of the current type.\n\"l=XX\" gives the length of the contents octets.\n\nThe -i option can be used to make the output more readable.\n\nSome knowledge of the ASN.1 structure is needed to interpret the output.\n\nIn this example the BIT STRING at offset 229 is the certificate public key.  The contents\noctets of this will contain the public key information. This can be examined using the option\n\"-strparse 229\" to yield:\n\n0:d=0  hl=3 l= 137 cons: SEQUENCE\n3:d=1  hl=3 l= 129 prim: INTEGER           :E5D21E1F5C8D208EA7A2166C7FAF9F6BDF2059669C60876DDB70840F1A5AAFA59699FE471F379F1DD6A487E7D5409AB6A88D4A9746E24B91D8CF55DB3521015460C8EDE44EE8A4189F7A7BE77D6CD3A9AF2696F486855CF58BF0EDF2B4068058C7A947F52548DDF7E15E96B385F86422BEA9064A3EE9E1158A56E4A6F47E5897\n135:d=1  hl=2 l=   3 prim: INTEGER           :010001\n"
                }
            ]
        },
        "NOTES": {
            "content": "If an OID is not part of OpenSSL's internal table it will be represented in numerical form\n(for example 1.2.3.4). The file passed to the -oid option allows additional OIDs to be\nincluded. Each line consists of three columns, the first column is the OID in numerical\nformat and should be followed by white space. The second column is the \"short name\" which is\na single word followed by whitespace. The final column is the rest of the line and is the\n\"long name\". Example:\n\n\"1.2.3.4       shortName       A long name\"\n\nFor any OID with an associated short and long name, this command will display the long name.\n",
            "subsections": []
        },
        "EXAMPLES": {
            "content": "Parse a file:\n\nopenssl asn1parse -in file.pem\n\nParse a DER file:\n\nopenssl asn1parse -inform DER -in file.der\n\nGenerate a simple UTF8String:\n\nopenssl asn1parse -genstr 'UTF8:Hello World'\n\nGenerate and write out a UTF8String, don't print parsed output:\n\nopenssl asn1parse -genstr 'UTF8:Hello World' -noout -out utf8.der\n\nGenerate using a config file:\n\nopenssl asn1parse -genconf asn1.cnf -noout -out asn1.der\n\nExample config file:\n\nasn1=SEQUENCE:seqsect\n\n[seqsect]\n\nfield1=BOOL:TRUE\nfield2=EXP:0, UTF8:some random string\n",
            "subsections": []
        },
        "BUGS": {
            "content": "There should be options to change the format of output lines. The output of some ASN.1 types\nis not well handled (if at all).\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "openssl(1), ASN1generatenconf(3)\n",
            "subsections": []
        },
        "COPYRIGHT": {
            "content": "Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved.\n\nLicensed under the Apache License 2.0 (the \"License\").  You may not use this file except in\ncompliance with the License.  You can obtain a copy in the file LICENSE in the source\ndistribution or at <https://www.openssl.org/source/license.html>.\n\n\n\n3.0.2                                        2026-06-02                      OPENSSL-ASN1PARSE(1SSL)",
            "subsections": []
        }
    },
    "summary": "openssl-asn1parse - ASN.1 parsing command",
    "flags": [
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Print out a usage message."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "The input format; the default is PEM. See openssl-format-options(1) for details."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "The input file, default is standard input."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Output file to place the DER encoded data into. If this option is not present then no data will be output. This is most useful when combined with the -strparse option."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Don't output the parsed version of the input file."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Starting offset to begin parsing, default is start of file."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Number of bytes to parse, default is until end of file."
        },
        {
            "flag": "-i",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "A file containing additional OBJECT IDENTIFIERs (OIDs). The format of this file is described in the NOTES section below."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Dump unknown data in hex format."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Like -dump, but only the first num bytes are output."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Parse the contents octets of the ASN.1 object starting at offset. This option can be used multiple times to \"drill down\" into a nested structure."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Generate encoded data based on string, file or both using ASN1generatenconf(3) format. If file only is present then the string is obtained from the default section using the name asn1. The encoded data is passed through the ASN1 parser and printed out as though it came from a file, the contents can thus be examined and written to a file using the -out option."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "If this option is used then -inform will be ignored. Without this option any data in a PEM format input file will be treated as being base64 encoded and processed whether it has the normal PEM BEGIN and END markers or not. This option will ignore any data prior to the start of the BEGIN marker, or after an END marker in a PEM file."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Attempt to decode and print the data as an ASN1ITEM name. This can be used to print out the fields of any supported ASN.1 structure if the type is known."
        }
    ],
    "examples": [
        "Parse a file:",
        "openssl asn1parse -in file.pem",
        "Parse a DER file:",
        "openssl asn1parse -inform DER -in file.der",
        "Generate a simple UTF8String:",
        "openssl asn1parse -genstr 'UTF8:Hello World'",
        "Generate and write out a UTF8String, don't print parsed output:",
        "openssl asn1parse -genstr 'UTF8:Hello World' -noout -out utf8.der",
        "Generate using a config file:",
        "openssl asn1parse -genconf asn1.cnf -noout -out asn1.der",
        "Example config file:",
        "asn1=SEQUENCE:seqsect",
        "[seqsect]",
        "field1=BOOL:TRUE",
        "field2=EXP:0, UTF8:some random string"
    ],
    "see_also": [
        {
            "name": "openssl",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/openssl/1/json"
        },
        {
            "name": "ASN1generatenconf",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/ASN1generatenconf/3/json"
        }
    ]
}