In this post we will cover how to convert a DER-encoded certificate with a CRT or CER extension to PEM format.
What are PEM and DER certificates?
CRT and CER are file extensions used for X.509 certificates. They are file extensions that do not define encoding or internal format.
A .crt or .cer file may contain:
- DER (binary ASN.1)
- PEM (Base64-encoded ASN.1 wrapped in ASCII headers).
These files may contain either DER (binary) encoded data or PEM (Base64 encoded) data (it depends on how they were issued).
Many Certificate Authorities (CAs) provide certificates in X.509 format (a file with a CER/CRT extension). In some environments (for example, Windows-based certificate stores), .cer/.crt files are commonly DER-encoded, while in web and Linux environments PEM format is more common.
However, the majority of services that use SSL Certificates will only accept certificates in PEM format (Base64 encoded). PEM is a Base64 encoding format that wraps ASN.1 binary data with ASCII headers and footers (the file commonly contains data originally encoded in DER format).
PEM
PEM files are plain text-based and supported by most web browsers, servers, and apps. Such file includes the header and footer lines: —–BEGIN CERTIFICATE—– and —–END CERTIFICATE—–.
DER (.der, .crt)
DER (Distinguished Encoding Rules) is a binary ASN.1 encoding format that defines a strict, unambiguous representation of X.509 certificate data.
Renaming Base64 CRT to PEM
Before converting a CER/CRT certificate file to PEM, check if the file already contains a certificate in Base64-encoded format. Open the certificate file in any text editor. If it contains ASCII text that starts and ends with one of the following prompts, it has already been converted to Base64 PEM format:
-----BEGIN CERTIFICATE-----
-----END CERTIFICATE-----
Keep in mind that each PEM block must have matching BEGIN/END headers. In case you will mix certificate and key markers, in will result in invalid files that cannot be parsed (by tools like OpenSSL).

Note that renaming a .crt or .cer file to .pem does not convert the encoding. It will only change the file extension (but does not modify the file content). This step is only valid for files that are already in Base64 (PEM) format.

In case the certificate is in binary DER format, you must convert it using a proper tool (such as OpenSSL or Windows Certificate Export Wizard) before using the .pem.

You can quickly check whether a certificate file uses PEM encoding by looking for the —–BEGIN CERTIFICATE—– marker:
Select-String -Path "C:\temp\mycert.cer" -Pattern '^-----BEGIN CERTIFICATE-----'
Note that the command above only checks for the PEM header. It does not verify that the file contains a valid X.509 certificate. To validate the certificate, you need to parse it with certutil/OpenSSL.
In order to check whether Windows can parse the file as an X.509 certificate, use certutil:
certutil -dump "C:\temp\mycert.cer"
The command above parses the certificate and displays its metadata. If the file is not a valid X.509 certificate, certutil will return an error.
Converting Binary CRT to PEM using the Certificate Export Wizard in Windows
In Windows, you can convert CERs to the PEM certificate file format using the built-in Certificate Export tool. It can be used to convert a CRT file or export an installed certificate from the certificate store.
Locate the CRT file and double-click to open it.

Or run the Certificate Manager MMC snap-in:
- certlm.msc – to export local machine certificate
- certmgr.msc – to export user certificate

Open the certificate properties, navigate to the Detail tab and click Copy to file.

Select Base-64 encoded X.509 (.CER) format in the Certificate Export Wizard and click Next.

Specify the filename to export and click Next (the filename extension will automatically be set to *.cer).

When the export is complete, you need to locate the exported CER file and rename its extension to .pem if required by your app.

Converting DER Certificates to PEM Using Certutil
You can also use Windows built-in Certutil utility that can convert DER-encoded certificates to Base64 (PEM) format without installing any third-party tools.
Run the following command:
certutil -encode "C:\temp\mycert.cer" "C:\temp\mycert.pem"
This command reads the source certificate and creates a Base64-encoded PEM file. After the conversion, open the output file in a text editor and verify that it contains the following header and footer:
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----
Tip. Certutil is available by default on Windows Server and most Windows client OSs, and it makes this tool a convenient option when OpenSSL is not installed.
Converting Binary CRT to PEM using OpenSSL
To convert SSL certificates into the appropriate format, you can use the OpenSSL library. OpenSSL is primarily a Linux tool available out-of-the-box in most distros, but you can also use it on Windows.
In order to install OpenSSL, use the OpenSSL for Windows port, or install it using the WinGet package manager:
Use a currently supported OpenSSL release. As of September 2026, OpenSSL 3.5.8 is the recommended LTS branch for long-term enterprise support. You should avoid OpenSSL 3.0, which reached end of public support on September 7, 2026, as well as the older 1.1.1 and earlier releases.
winget install ShiningLight.OpenSSL.Light

The command and syntax for converting a binary CRT file to PEM is the same whether you’re using Linux or Windows:
openssl x509 -in <BINARY CRT FILE> -inform DER -out <PEM OUTPUT FILE> -outform PEM
Go to the directory with the OpenSSL binaries:
cd "C:\Program Files\OpenSSL-Win64\bin"
Convert the certificate file:
./openssl x509 -in "C:\temp\mycert.cer" -inform DER -out "C:\temp\mycert_converted.pem" -outform PEM

Note. The openssl x509 command converts only one X.509 certificate at a time. If you need to create a PEM certificate chain, you should first convert each certificate to PEM and then concatenate the server certificate and intermediate CA certificates in the required order. Here is an example:
Get-Content "C:\temp\server.pem","C:\temp\intermediate.pem" |
Set-Content "C:\temp\fullchain.pem"The resulting fullchain.pem contains the server certificate followed by the intermediate CA certificate. The root CA certificate is usually not included in the server’s certificate chain because clients are expected to have trusted root CAs in their trust stores.
Open the PEM file in any text editor and confirm that it contains ASCII text.

After conversion, you need to verify the certificate details:
openssl x509 -in mycert_converted.pem -text -noout
In case you need to convert PEM back to DER format, use the following command:
openssl x509 -in mycert.pem -inform PEM -out mycert.der -outform DER
Converting PFX/P12 to PEM Using OpenSSL
In case you have a PKCS#12 certificate bundle (.pfx or .p12), you can use OpenSSL to extract the certificate, private key, and CA certificates into separate PEM files. A PFX/P12 file can contain the certificate, its private key, and additional certificates such as intermediate CAs. This makes PKCS#12 different from a .cer or .crt file, which normally contains only the certificate.
Extracting the Certificate
In order to export the end-entity certificate without the private key, use the following command:
openssl pkcs12 -in "cert.pfx" -clcerts -nokeys -out "cert.pem"
OpenSSL will prompt for the PFX password if the container is protected.
Extracting the Private Key
In order to export the private key, run the command:
openssl pkcs12 -in "cert.pfx" -nocerts -out "key.pem"
The private key remains encrypted in the output PEM file. If the app requires an unencrypted private key, use the following:
openssl pkcs12 -in "cert.pfx" -nocerts -out "key.pem" -noenc
Warning. A PEM file containing a private key is sensitive. You need to protect it with appropriate file permissions and never upload it to source control, ticketing systems, or public locations.
On Linux, you can restrict access to the private key with:
chmod 600 key.pem
Extracting the CA Chain
In case the PFX/P12 container contains intermediate CA certificates, you can export them with the command:
openssl pkcs12 -in "cert.pfx" -cacerts -nokeys -out "chain.pem"
You can then use the certificate, private key, and CA chain as separate PEM files when required by the target app.
Automating Bulk Certificate Conversion
If you need to convert multiple certificates, you can automate the process with PowerShell. Use our example below to convert all DER-encoded *.cer files in a folder to PEM format using OpenSSL:
Get-ChildItem "C:\Certs" -File |
Where-Object Extension -in ".cer", ".crt", ".der" |
ForEach-Object {
$pemFile = [System.IO.Path]::ChangeExtension($_.FullName, ".pem")
# Try to read the certificate as PEM first.
# OpenSSL uses PEM as the default input format for x509.
& openssl x509 -in $_.FullName -noout 2>$null
if ($LASTEXITCODE -eq 0) {
Write-Host "Already PEM-encoded certificate: $($_.Name)"
Copy-Item $_.FullName $pemFile -Force
}
else {
& openssl x509 -in $_.FullName -inform DER -out $pemFile -outform PEM
if ($LASTEXITCODE -eq 0) {
Write-Host "Converted: $($_.Name) -> $([System.IO.Path]::GetFileName($pemFile))"
}
else {
Write-Warning "Skipping '$($_.Name)': not a valid X.509 certificate."
Remove-Item $pemFile -ErrorAction SilentlyContinue
}
}
}
This method can be very helpful in case you are migrating large numbers of certificates or preparing certificate stores for Linux-based apps.
Automating Bulk Certificate Conversion on Linux
In case you need to convert multiple DER-encoded certificates on Linux, you can automate the process with Bash and OpenSSL.
Converting a Single Certificate
Use the following command to convert a DER-encoded certificate to PEM format:
openssl x509 \
-in /etc/certs/mycert.cer \
-inform DER \
-out /etc/certs/mycert.pem \
-outform PEM
Now you need to verify the resulting PEM certificate:
openssl x509 -in /etc/certs/mycert.pem -noout -subject -issuer -dates
Converting Multiple Certificates
If a directory contains multiple DER-encoded .der certificates, you can convert them in a Bash loop:
for cert in /etc/certs/*.der; do
[ -f "$cert" ] || continue
openssl x509 -in "$cert" -inform DER \
-out "${cert%.der}.pem" \
-outform PEM
done
Our script creates a .pem file next to each .der certificate. It assumes that the input files are DER-encoded X.509 certificates.
What is the difference between CRT, CER, DER, and PEM?
CRT and CER are file extensions, not formats. They can contain either DER (binary ASN.1) or PEM (Base64-encoded ASN.1 with headers). DER is a binary encoding format, while PEM is a text-based container that wraps Base64-encoded data with headers like —–BEGIN CERTIFICATE—–.
How can I tell if my certificate is DER or PEM?
Open the file in a text editor:
- If you see readable text with —–BEGIN …—–, it’s PEM.
- If the file looks like binary/garbled data, it’s likely DER.
You can also use PowerShell:
- If the first line starts with —–BEGIN, it’s PEM.
- A binary check (like first byte 0x30) may indicate DER, but this is only a heuristic.
Can I convert a certificate by just renaming .crt to .pem?
No. Renaming does not convert the file format—it only changes the extension. This works only if the file is already in PEM format.
How do I convert a DER certificate to PEM in Windows?
Use the Certificate Export Wizard:
- Open the certificate
- Go to Details → Copy to file
- Choose Base-64 encoded X.509 (.CER)
- Export the file (optionally rename to .pem afterward)
Why do some systems require PEM instead of DER?
Many web servers and Linux-based tools expect text-based PEM format because it is easier to parse, copy, and combine with keys and chains.
