What Is a PEM File? (2024)

What to Know

  • A PEM file is a Privacy Enhanced Mail Certificate file.
  • Open one with the program or operating system that requires the file (they all work a bit differently).
  • Convert to PPK, PFX, or CRT with a command or special converter.

This article explains what PEM files are used for, how to open one depending on the program or OS you're using, and how to convert one to a different certificate file format.

What Is a PEM File?

A PEM file is a Privacy Enhanced Mail Certificate file used to privately transmit email. The person receiving this emailcan be confident that the message wasn't altered during its transmission, wasn't shown to anyone else, and was sent by the person who claims to have sent it.

PEM files arose out of the complication of sending binary data through email. The PEM format encodes binary with base64 so that it exists as an ASCII string.

The PEM format has been replaced by newer and more secure technologies, but the PEM container is still used today to hold certificate authority files, public and private keys, root certificates, etc.

Some files in the PEM format might instead use a different file extension, like CER or CRT for certificates, or KEY for public or private keys.

How to Open PEM Files

The steps for opening a PEM file are different depending on the application that needs it and the operating system you're using. However, you might need to convert your PEM file to CER or CRT in order for some of these programs to accept the file.

Windows

If you need the CER or CRT file in a Microsoft email client like Outlook, open it in Internet Explorer to have it automatically loaded into the proper database. The email client can automatically use it from there.

Microsoft no longer supports Internet Explorer and recommends that you update to the newer Edge browser. Head to their site to download the newest version.

To see which certificate files are loaded onto your computer, and to import ones manually, use Internet Explorer's Tools menu to access Internet Options > Content > Certificates, like this:

What Is a PEM File? (1)

To import a CER or CRT file into Windows, start by opening Microsoft Management Console from the Run dialog box (use the Windows Key + R keyboard shortcut to enter mmc). From there, go to File > Add/Remove Snap-in... and select Certificates from the left column, and then the Add > button in the center of the window.

Choose Computer account on the following screen, and then move through the wizard, selecting Local computer when asked. Once "Certificates" is loaded under "Console Root," expand the folder and right-click Trusted Root Certification Authorities, and choose All Tasks > Import.

macOS

The same concept is true for your Mac email client as it is for a Windows one: use Safari to have the PEM file imported into Keychain Access.

You can also import SSL certificates through the File > Import Items menu in Keychain Access. Choose System from the drop-down menu and then follow the on-screen prompts.

What Is a PEM File? (3)

If these methods don't work for importing the PEM file into macOS, you might try the following command (change "yourfile.pem" to be the name and location of your specific PEM file):

security import yourfile.pem -k ~/Library/Keychains/login.keychain

Linux

Use this keytool command to view the contents of a PEM file on Linux:

keytool -printcert -file yourfile.pem

Follow these steps if you want to import a CRT file into Linux's trusted certificate authority repository (see the PEM to CRT conversion method in the next section below if you have a PEM file instead):

  1. Navigate to /usr/share/ca-certificates/.

  2. Create a folder there (for example, sudo mkdir /usr/share/ca-certificates/work).

  3. Copy the .CRT file into that newly created folder. If you'd rather not do it manually, you can use this command instead: sudo cp yourfile.crt /usr/share/ca-certificates/work/yourfile.crt.

  4. Make sure the permissions are set correctly (755 for the folder and 644 for the file).

  5. Run the sudo update-ca-certificates command.

Firefox and Thunderbird

If the PEM file needs importing into a Mozilla email client like Thunderbird, you might have to first export the PEM file out of Firefox. Open the Firefox menu and choose Options. Go to Privacy & Security and find the Security section, and then use the View Certificates... button to open a list, from where you can select the one you need to export. Use the Backup... option to save it.

Then, in Thunderbird, open the menu and click or tap Options. Navigate to Advanced > Certificates > Manage Certificates > Your Certificates > Import. From the "File name:" section of the Import window, choose Certificate Files from the drop-down, and then find and open the PEM file.

To import the PEM file into Firefox, just follow the same steps you would to export one, but choose Import instead of the Backup... button. If you can't find the PEM file, make sure the "Filename" area of the dialog box is set to Certificate Files and not PKCS12 Files.

Java KeyStore

Stack Overflow has a thread about importing a PEM file into the Java KeyStore (JKS) if you need to do that. Another option that might work is to use this keyutil tool.

How to Convert a PEM File

Unlike most file formats that can be converted with a file conversion tool or website, you need to enter special commands against a particular program in order to convert the PEM file format to most other formats.

Convert PEM to PPK with PuTTYGen. Choose Load from the right side of the program, set the file type to be any file (*.*), and then browse for and open your PEM file. Choose Save private key to make the PPK file.

With OpenSSL (get the Windows version here), you can convert the PEM file to PFX with the following command:

openssl pkcs12 -inkey yourfile.pem -in yourfile.cert -export -out yourfile.pfx

If you have a PEM file that needs to be converted to CRT, like is the case with Ubuntu, use this command with OpenSSL:

openssl x509 -in yourfile.pem -inform PEM -out yourfile.crt

OpenSSL also supports converting .PEM to .P12 (PKCS#12, or Public Key Cryptography Standard #12), but append the ".TXT" file extension at the end of the file before running this command:

openssl pkcs12 -export -inkey yourfile.pem.txt -in yourfile.pem.txt -out yourfile.p12

See the Stack Overflow link above about using the PEM file with Java KeyStore if you want to convert the file to JKS, or this tutorial from Oracle to import the file into the Java truststore.

More Information on PEM

The data integrity feature of the Privacy Enhanced Mail Certificate format uses RSA-MD2 and RSA-MD5 message digests to compare a message before and after it's sent, to ensure that it hasn't been tampered with along the way.

At the beginning of a PEM file is a header that reads -----BEGIN [label]-----, and the end of the data is a similar footer like this: -----END [label]-----. The "[label]" section describes the message, so it might read PRIVATE KEY, CERTIFICATE REQUEST, or CERTIFICATE.

Here's an example:

-----BEGIN PRIVATE KEY-----
MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAMLgD0kAKDb5cFyP
jbwNfR5CtewdXC+kMXAWD8DLxiTTvhMW7qVnlwOm36mZlszHKvsRf05lT4pegiFM
9z2j1OlaN+ci/X7NU22TNN6crYSiN77FjYJP464j876ndSxyD+rzys386T+1r1aZ
aggEdkj1TsSsv1zWIYKlPIjlvhuxAgMBAAECgYA0aH+T2Vf3WOPv8KdkcJg6gCRe
yJKXOWgWRcicx/CUzOEsTxmFIDPLxqAWA3k7v0B+3vjGw5Y9lycV/5XqXNoQI14j
y09iNsumds13u5AKkGdTJnZhQ7UKdoVHfuP44ZdOv/rJ5/VD6F4zWywpe90pcbK+
AWDVtusgGQBSieEl1QJBAOyVrUG5l2234raSDfm/DYyXlIthQO/A3/LngDW
5/ydGxVsT7lAVOgCsoT+0L4efTh90PjzW8LPQrPBWVMCQQDS3h/FtYYd5lfz+FNL
9CEe1F1w9l8P749uNUD0g317zv1tatIqVCsQWHfVHNdVvfQ+vSFw38OORO00Xqs9
1GJrAkBkoXXEkxCZoy4PteheO/8IWWLGGr6L7di6MzFl1lIqwT6D8L9oaV2vynFT
DnKop0pa09Unhjyw57KMNmSE2SUJAkEArloTEzpgRmCq4IK2/NpCeGdHS5uqRlbh
1VIa/xGps7EWQl5Mn8swQDel/YP3WGHTjfx7pgSegQfkyaRtGpZ9OQJAa9Vumj8m
JAAtI0Bnga8hgQx7BhTQY4CadDxyiRGOGYhwUzYVCqkb2sbVRH9HnwUaJT7cWBY3
RnJdHOMXWem7/w==
-----END PRIVATE KEY-----

One PEM file can contain multiple certificates, in which case the "END" and "BEGIN" sections neighbor each other.

Still Can't Open the File?

One reason your file doesn't open in any of the ways described above is that you're not actually dealing with a PEM file. You might instead have a file that just uses a similarly spelled file extension. When that's the case, there isn't a necessity for the two files to be related or for them to work with the same software programs.

For example, PEF looks an awful lot like PEM but instead belongs to either the Pentax Raw Image file format or Portable Embosser Format. Follow that link to see how to open or convert PEF files, if that's what you really have.

The same could be said for many other file extensions like EPM, EMP, EPP, PES, PET...you get the idea. Just double-check the file extension to see that it actually reads ".pem" before considering that the methods above don't work.

If you're dealing with a KEY file, be aware that not all files that end in .KEY belongs in the format described on this page. They might instead be Software License Key files used when registering software programs like LightWave, or Keynote Presentation files created by Apple Keynote.

FAQ

  • How do I create a PEM file?

    The first step toward creating a PEM file is to download the certificates your certificate authority sent you. This will include an intermediate certificate, a root certificate, a primary certificate, and private key files.

    Next, open a text editor, such as WordPad or Notepad, and paste the body of each certificate into a new text file. They should be in this order: Private Key, Primary Certificate, Intermediate Certificate, Root Certificate. Add starting and ending tags. They’ll look like this:

    -----BEGIN CERTIFICATE ----- and -----END CERTIFICATE -----

    Finally, save the file as your_domain.pem.

  • Is a PEM file the same thing as a CRT file?

    No. PEM and CRT files are related; both file types represent different aspects of the key generation and verification process. PEM files are containers meant to verify and decrypt data that a server sends. A CRT (which stands for certificate) file represents a certificate signing request. CRT files are a way to verify ownership without private key access. CRT files contain the public key along with much more information.

Was this page helpful?

Thanks for letting us know!

Get the Latest Tech News Delivered Every Day

Subscribe

Tell us why!

What Is a PEM File? (2024)

FAQs

What is a PEM file used for? ›

Privacy Enhanced Mail (PEM) files are a type of Public Key Infrastructure (PKI) file used for keys and certificates. PEM, initially invented to make e-mail secure, is now an Internet security standard.

Does a PEM file contain a private key? ›

A PEM file may contain just about anything including a public key, a private key, or both, because a PEM file is not a standard. In effect PEM just means the file contains a base64-encoded bit of data.

Is PEM same as key file? ›

. key files are generally the private key, used by the server to encrypt and package data for verification by clients. . pem files are generally the public key, used by the client to verify and decrypt data sent by servers.

What is PEM file how do you open it? ›

PEM files are typically imported from a Unix-based Apache Web server and compatible with OpenSSL applications. PEM file open in Microsoft Notepad. Secure certificates, like PEM-encoded X. 509 certificates, are a way to verify the security and authenticity of an organization online.

Is it OK to share PEM file? ›

Save this answer. Show activity on this post. The pem file for Google Chrome extensions are private keys and should not be distributed.

What is difference between PEM and ssh? ›

pub file format is used by SSH for public key store, this key need to share with a Server. . pem (Privacy Enhanced Mail) is a base64 container format for encoding keys and certificates. . pem download from AWS when you created your key-pair.

How can I get private key from PEM file? ›

Generate SSH Keys in PEM Format to Connect to a Public or On-Premises sFTP Server
  1. Verify the key by opening the file in Notepad. The key must start with the following phrase. ...
  2. Use -m PEM with ssh-keygen to generate private keys in PEM format: Copy ssh-keygen -t rsa -m PEM.

How you can access a machine without a .PEM key? ›

This init script is executed during instance startup perform the following actions:
  1. Update the packages.
  2. Install Python.
  3. Install AWS CLI.
  4. Copy and replace the sshd_config script from S3 to EC2 instance.
  5. Change appropriate permission.
  6. Restart the SSH service.
  7. And finally, assign the password to the “ubuntu” user.

How to convert PEM file to private key? ›

PEM to PPK conversion steps
  1. Download PuTTYGen from puttygen.com.
  2. Open PuTTYGen and click the Load button.
  3. Set the filetype to *. * so the AWS PEM file is visible.
  4. Select your PEM file and PuTTYGen will import it.
  5. Click Save Private Key and PuTTYGen will convert the PEM to a PPK file.
Feb 8, 2022

What is .PEM file in SSL? ›

SSL . pem files (concatenated certificate container files), are frequently required for certificate installations when multiple certificates are being imported as one file. This article contains multiple sets of instructions that walk through various .

What should a PEM file look like? ›

A PEM file is a text file containing one or more items in Base64 ASCII encoding, each with plain-text headers and footers (e.g. -----BEGIN CERTIFICATE----- and -----END CERTIFICATE----- ).

How to convert key to PEM format? ›

Convert your user key and certificate files to PEM format.
  1. Get the . key. pem file. For example: openssl pkcs12 -nocerts -in my.p12 -out .key.pem.
  2. Get the . cert. pem file. ...
  3. Remove the passphrase from the key. For example: openssl rsa -in .key.pem -out key_nopass.pem mv key_nopass.pem .key.pem.

How to use a PEM file for ssh? ›

How to connect to an EC2 instance using SSH using Linux
  1. Open your terminal and change directory with command cd, where you downloaded your pem file. ...
  2. Type the SSH command with this structure: ssh -i file.pem username@ip-address. ...
  3. After pressing enter, a question will prompt to add the host to your known_hosts file.

What is difference between PFX and PEM? ›

A PEM encoded file contains a private key or a certificate. PFX is a keystore format used by some applications. A PFX keystore can contain private keys or public keys. The information that follows explains how to transform your PFX or PEM keystore into a PKCS12 keystore.

What is difference between PEM and PPK? ›

pem and . ppk formats are similar in that both of them store the private key information of asymmetric key pairs. The difference between them, however, is the way the private key is stored in the file.

How do I generate a private key from a .PEM file? ›

Generate SSH Keys in PEM Format to Connect to a Public or On-Premises sFTP Server
  1. Verify the key by opening the file in Notepad. The key must start with the following phrase. ...
  2. Use -m PEM with ssh-keygen to generate private keys in PEM format: Copy ssh-keygen -t rsa -m PEM.

Can I use PEM key with PuTTY? ›

PuTTY doesn't natively support the private key format (. pem) generated by Amazon EC2. You must convert your private key into a . ppk file before you can connect to your instance using PuTTY.

How do I use a PEM certificate? ›

Using the pem files, you can store the SSL certificates with their associated private keys. More than one certificates are assigned in the full SSL chain, and they work in the following order: First, an end-user certificate, generally assigned to the domain name by a certificate authority (CA).

How do I import a PEM certificate? ›

Procedure
  1. Select Tools > Options > Advanced.
  2. Select Certificates, then click the View Certificates button. ...
  3. Click Import and select the cacert. ...
  4. When a dialog is displayed, ensure that the following option is checked: Trust this CA to identify websites.
  5. Click the OK button.

Top Articles
Latest Posts
Article information

Author: Barbera Armstrong

Last Updated:

Views: 5328

Rating: 4.9 / 5 (59 voted)

Reviews: 90% of readers found this page helpful

Author information

Name: Barbera Armstrong

Birthday: 1992-09-12

Address: Suite 993 99852 Daugherty Causeway, Ritchiehaven, VT 49630

Phone: +5026838435397

Job: National Engineer

Hobby: Listening to music, Board games, Photography, Ice skating, LARPing, Kite flying, Rugby

Introduction: My name is Barbera Armstrong, I am a lovely, delightful, cooperative, funny, enchanting, vivacious, tender person who loves writing and wants to share my knowledge and understanding with you.