What is a PEM file?
PEM Stands for Privacy-Enhanced Mail (PEM), is a file format for storing and sending cryptographic keys, certificates, and other data.PEM was initially invented to make e-mail secure. PEM file can be used for multiple purposes.
The .pem file defines the structure and encoding file type that is used to store the data using base64.
PEM File Format
![PEM file]()
The label determines the type of message encoded. Common labels include CERTIFICATE
, CERTIFICATE REQUEST
, PRIVATE KEY
and X509 CRL
.A single PEM file can contain multiple blocks.
Examples. For Private key
For Certificate
PEM data is commonly stored in files with a ".pem" suffix, a ".cer" or ".crt" suffix (for certificates), or a ".key" suffix (for public or private keys).
The label inside a PEM file represents the type of data more accurately than the file suffix since many different types of data can be saved in a ".pem" file.
In particular, PEM refers to the header and base64 wrapper for a binary format contained within but does not specify any type or format for the binary data, so that a PEM file may contain "almost anything base64 encoded and wrapped with BEGIN and END lines".
Why base64?
PEM format encodes binary with base64 so that it exists as an ASCII string.
Conclusion
In this article, we have gone through what is a PEM file, is basic format, different supporting file types, and why .pem file is encoded in base64.