# DER

DER (Distinguished Encoding Rules) is the binary ASN.1 encoding that X.509 certificates, CSRs and keys are actually defined in. A DER file holds exactly one object with no header, footer or delimiter of any kind, which is why several DER certificates cannot be concatenated into a chain the way PEM ones can. Every DER file of a standard type starts with byte `0x30`, the ASN.1 tag for SEQUENCE. PEM is this same binary data Base64-encoded and labelled.

Source: https://certguru.io/formats/der/
Last updated: 2026-08-19
Commands verified against OpenSSL 3.5.7.

---

## What it is

DER is the wire format. X.509 certificates are defined in ASN.1, an abstract description of data
structures, and DER is one set of rules for turning that abstraction into bytes. When a certificate
is signed, it is the DER bytes that get hashed — which is why the encoding must be deterministic.
BER, DER's more permissive parent, allows several valid encodings of the same value; DER allows
exactly one.

*The first bytes of any DER certificate*

```bash
head -c 4 certificate.der | xxd
```

Expected output:

```
00000000: 3082 05a1                                0...
```

`30` is the ASN.1 tag for SEQUENCE. `82` says the length is encoded in the next two bytes.
`05a1` is that length — 1441 bytes. Every standard DER file starts this way, which makes it easy
to recognise.

## Identifying a DER file

```bash
file certificate.der
```

Expected output:

```
certificate.der: Certificate, Version=3
```

Or check the first byte directly, which works without `file` installed:

```bash
head -c 1 certificate.der | xxd -p
```

Expected output:

```
30
```

> **The failure mode to recognise**
>
> Passing a DER file to a command that expects PEM produces
>   `PEM routines::no start line`. That error means "I looked for `-----BEGIN` and found binary" — the
>   fix is `-inform der`, not a different file. See
>   [that error explained](/errors/pem-routines-no-start-line/).

## Reading a DER file

Every OpenSSL subcommand takes `-inform der`:

*Inspect a DER certificate without converting it*

```bash
openssl x509 -inform der -in certificate.der -noout -text
```

*A DER private key*

```bash
openssl pkey -inform der -in private.der -noout -text
```

## Where DER shows up in practice

- **Certificates published by CAs.** The Authority Information Access extension points at an
  intermediate that is nearly always DER, which is why
  [DER to PEM](/convert/der-to-pem/) is such a common conversion.
- **Windows exports.** The certificate export wizard offers "DER encoded binary X.509" and writes
  it with a `.cer` extension.
- **Java keystores, PKCS#7 and PKCS#12.** All three are DER-encoded containers. The container is
  binary even when the certificates inside it came from PEM files.
- **Constrained devices.** Skipping Base64 saves about 25% of the bytes, which matters on embedded
  systems and not much anywhere else.

## Converting

```bash
openssl x509 -inform der -in certificate.der -out certificate.pem
```

```bash
openssl x509 -in certificate.pem -outform der -out certificate.der
```

The conversion is lossless in both directions and the fingerprint does not change, because the
fingerprint is a hash of the DER bytes either way:

```bash
openssl x509 -in certificate.pem -noout -fingerprint -sha256
openssl x509 -inform der -in certificate.der -noout -fingerprint -sha256
```

## DER compared with PEM

| | DER | PEM |
| --- | --- | --- |
| Encoding | Raw binary | Base64 text |
| Objects per file | One | Many |
| Readable in an editor | No | Yes |
| Safe to paste into a terminal or ticket | No | Yes |
| Size | ~25% smaller | Larger |
| Typical extension | `.der`, `.cer` | `.pem`, `.crt`, `.key` |
| OpenSSL flag needed | `-inform der` | none (the default) |


## Frequently asked questions

### What does DER stand for?

Distinguished Encoding Rules. It is a restricted subset of BER (Basic Encoding Rules) in which every value has exactly one valid encoding. That determinism is essential for signatures, because a certificate has to serialise identically everywhere or its signature would not verify.

### Can a DER file hold a certificate chain?

Not reliably. DER has no delimiters, so concatenated certificates cannot be split apart again with any certainty. A binary file that holds several certificates is almost always PKCS#7 or PKCS#12, both of which are themselves DER-encoded containers.

### How do I tell DER from PEM?

Look at the first byte. `0x30` means DER. A `-` character (the start of `-----BEGIN`) means PEM. `head -c 2 file | xxd` answers it in one command.

### Is DER more secure than PEM?

No. They encode identical data and offer identical protection, which is to say none — neither format encrypts anything by itself. A DER private key is exactly as exposed as a PEM one.


## References

- [RFC 5280: X.509 and CRL profile](https://www.rfc-editor.org/rfc/rfc5280) — the specification every field on a certificate comes from
- [RFC 7468: textual encodings of PKIX structures](https://www.rfc-editor.org/rfc/rfc7468) — defines the PEM armour and what may sit between the BEGIN and END lines

## Related pages

- https://certguru.io/formats/pem/
- https://certguru.io/convert/der-to-pem/
- https://certguru.io/convert/pem-to-der/
- https://certguru.io/formats/crt-cer/
- https://certguru.io/errors/pem-routines-no-start-line/

--
CertGuru — https://certguru.io
