Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4079742
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T17:50:27+00:00 2026-05-20T17:50:27+00:00

I need to parse .PEM files. I know that the standard for Privacy-enhanced Electronic

  • 0

I need to parse .PEM files.
I know that the standard for “Privacy-enhanced Electronic Mail” is defined in RFCs 1421-24. But they don’t seem to mention some text I find inside OpenSSL .pem files (eg. “Key Attributes”, “BEGIN CERTIFICATE”, etc…)
Is this an OpenSSL-specific format?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T17:50:28+00:00Added an answer on May 20, 2026 at 5:50 pm

    For quite a long time, there was no formal specification of the PEM format with regards to cryptographic exchange of information. PEM is the textual encoding, but what is actually being encoded depends on the context. In April 2015, the IETF approved RFC 7468, which finally documents how various implementations exchange data using PEM textual encoding. The following list, taken directly from the RFC, describes the PEM format used for the following scenarios:

    1. Certificates, Certificate Revocation Lists (CRLs), and Subject
      Public Key Info structures in the Internet X.509 Public Key
      Infrastructure Certificate and Certificate Revocation List (CRL)
      Profile [RFC5280].
    2. PKCS #10: Certification Request Syntax [RFC2986].
    3. PKCS #7: Cryptographic Message Syntax [RFC2315].
    4. Cryptographic Message Syntax [RFC5652].
    5. PKCS #8: Private-Key Information Syntax [RFC5208], renamed to One
      Asymmetric Key in Asymmetric Key Package [RFC5958], and Encrypted
      Private-Key Information Syntax in the same documents.
    6. Attribute Certificates in An Internet Attribute Certificate
      Profile for Authorization [RFC5755].

    According to this RFC, for the above scenarios you can expect the following labels to be within the BEGIN header and END footer. Figure 4 of the RFC has more detail, including corresponding ASN.1 types.

    • CERTIFICATE [RFC5280]
    • X509 CRL [RFC5280]
    • CERTIFICATE REQUEST [RFC2986]
    • PKCS7 [RFC2315]
    • CMS [RFC5652]
    • PRIVATE KEY [RFC5208] [RFC5958]
    • ENCRYPTED PRIVATE KEY [RFC5958]
    • ATTRIBUTE CERTIFICATE [RFC5755]
    • PUBLIC KEY [RFC5280]

    That’s not the full story, though. The RFC was written by looking at existing implementations and documenting what they did. The RFC wasn’t written first, nor was it written based on some existing authoritative documentation. So if you end up in a situation where you want to inter-operate with some implementation, you may have to look into the implementation’s source code to figure out what they support.

    For example, OpenSSL defines these BEGIN and END markers in crypto/pem/pem.h. Here is an excerpt from the header file with all the BEGIN and END labels that they support.

    # define PEM_STRING_X509_OLD     "X509 CERTIFICATE"
    # define PEM_STRING_X509         "CERTIFICATE"
    # define PEM_STRING_X509_TRUSTED "TRUSTED CERTIFICATE"
    # define PEM_STRING_X509_REQ_OLD "NEW CERTIFICATE REQUEST"
    # define PEM_STRING_X509_REQ     "CERTIFICATE REQUEST"
    # define PEM_STRING_X509_CRL     "X509 CRL"
    # define PEM_STRING_EVP_PKEY     "ANY PRIVATE KEY"
    # define PEM_STRING_PUBLIC       "PUBLIC KEY"
    # define PEM_STRING_RSA          "RSA PRIVATE KEY"
    # define PEM_STRING_RSA_PUBLIC   "RSA PUBLIC KEY"
    # define PEM_STRING_DSA          "DSA PRIVATE KEY"
    # define PEM_STRING_DSA_PUBLIC   "DSA PUBLIC KEY"
    # define PEM_STRING_PKCS7        "PKCS7"
    # define PEM_STRING_PKCS7_SIGNED "PKCS #7 SIGNED DATA"
    # define PEM_STRING_PKCS8        "ENCRYPTED PRIVATE KEY"
    # define PEM_STRING_PKCS8INF     "PRIVATE KEY"
    # define PEM_STRING_DHPARAMS     "DH PARAMETERS"
    # define PEM_STRING_DHXPARAMS    "X9.42 DH PARAMETERS"
    # define PEM_STRING_SSL_SESSION  "SSL SESSION PARAMETERS"
    # define PEM_STRING_DSAPARAMS    "DSA PARAMETERS"
    # define PEM_STRING_ECDSA_PUBLIC "ECDSA PUBLIC KEY"
    # define PEM_STRING_ECPARAMETERS "EC PARAMETERS"
    # define PEM_STRING_ECPRIVATEKEY "EC PRIVATE KEY"
    # define PEM_STRING_PARAMETERS   "PARAMETERS"
    # define PEM_STRING_CMS          "CMS"
    

    These labels are a start, but you still have to look into how the implementation encodes the data between the labels. There’s not one correct answer for everything.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a rather big number of source files that I need parse and
I need to parse html emails that will be similar but not exactly the
Need to parse a file for lines of data that start with this pattern
I need to parse a file but the data is in a strange format
I need to parse some XML that triggers an NSURLConnection. After the parsing finished,
I need to parse .net TimeSpan on jQuery, I'm trying through jQuery globalization but
I need to parse some files in the background mode. How can I do
I need to parse an RSS feed using PHP but the server only has
I am creating a script which need to parse the yaml output that the
I need to parse potentially huge XML files, so I guess this rules out

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.