70
$\begingroup$

I'm new to SSL / TLS and I want to work with the OpenSSL toolkit.

I don't know what .pem and .csr stands for?

I do know that .key is the private key and .crt is the public key.

$\endgroup$
95
$\begingroup$

File extensions can be (very) loosely seen as a type system.

  • .pem stands for PEM, Privacy Enhanced Mail; it simply indicates a base64 encoding with header and footer lines. Mail traditionally only handles text, not binary which most cryptographic data is, so some kind of encoding is required to make the contents part of a mail message itself (rather than an encoded attachment). The contents of the PEM are detailed in the header and footer line - .pem itself doesn't specify a data type - just like .xml and .html do not specify the contents of a file, they just specify a specific encoding;
  • .key can be any kind of key, but usually it is the private key - OpenSSL can wrap private keys for all algorithms (RSA, DSA, EC) in a generic and standard PKCS#8 structure, but it also supports a separate 'legacy' structure for each algorithm, and both are still widely used even though the documentation has marked PKCS#8 as superior for almost 20 years; both can be stored as DER (binary) or PEM encoded, and both PEM and PKCS#8 DER can protect the key with password-based encryption or be left unencrypted;
  • .csr or .p10 stands for Certificate Signing Request as defined in PKCS#10, it contains information such as the public key and common name required by a Certificate Authority to create and sign a certificate for the requester, the encoding could be PEM or DER (which is a binary encoding of an ASN.1 specified structure);
  • .crt stands simply for certificate, usually an X509v3 certificate, again the encoding could be PEM or DER; a certificate contains the public key, but it contains much more information (most importantly the signature by the Certificate Authority over the data and public key, of course).

There are quite a few other extensions that you will find as well:

  • .p8, .pkcs8 are private keys. PKCS#8 defines a way to encrypt private keys using e.g. a password. However, quite often, only the inner unencrypted PKCS#8 structure is used instead (which just defines the type of key). The inner structure can then e.g. contain a PKCS#1 formatted private key for RSA or an X.62 one for Elliptic Curves. PKCS#8 is generally not transported, so commonly it is DER encoded, but not PEM encoded;
  • .p12 or .pkix is a PKCS#12 defined key store, commonly password protected. It can contain trusted certificates, private keys and their key chains, but also other information such as secret keys and (very uncommonly) other personal information; .p12 is usually binary / DER encoded.
  • .crl is a Certificate Revocation List which is defined within the X.509v3 certificate specifications, and this is usually DER encoded as well.

Beware that not everyone may use the same extensions - there is no official register or anything like that. You're probably better off using the POSIX file command line utility first.


There are also proprietary formats that are relatively common.

  • .jks stands for Java Key Store. It is a PKIX specific key store that can be used to store private keys with their certificate chains (root CA, intermediate CA's, leaf certificates or just a single self-signed certifciate) as well as providing a trust store. .jks key stores are password protected, but they have been deprecated by enhanced support for PKCS#12.
$\endgroup$
  • $\begingroup$ If you update this Q/A with JKS, we can dupe this $\endgroup$ – kelalaka Jul 30 at 19:19
  • 1
    $\begingroup$ @kelalaka Extended answer significantly and made it community wiki. $\endgroup$ – Maarten Bodewes Jul 30 at 21:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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