> For the complete documentation index, see [llms.txt](https://docs.arkannis.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.arkannis.net/os/linux/openssl/openssl-cert-conversion.md).

# OpenSSL cert conversion

#### Convert PFX to PEM

```bash
openssl pkcs12 -in certificate.pfx -out certificate.cer -nodes
```

#### Convert PEM to PFX

```
 openssl pkcs12 -export -out certificate.pfx -inkey privateKey.key -in certificate.crt -certfile CACert.crt 
```

#### Convert P7B to PEM

```bash
openssl pkcs7 -print_certs -in certificate.p7b -out certificate.cer
```

#### Convert P7B to PFX

{% hint style="info" %}
Note: This requires 2 commands
{% endhint %}

```bash
# Step 1
openssl pkcs7 -print_certs -in certificate.p7b -out certificate.cer

# Step 2
openssl pkcs12 -export -in certificate.cer -inkey privateKey.key -out certificate.pfx -certfile CACert.cer
openssl pkcs7 -print_certs -in old.p7b -out new.crt
```

#### Convert DER to PEM

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

#### Convert DER to CRT<br>

Use the following command to convert a DER encoded certificate into a PEM encoded certificate:

```bash
openssl x509 -inform DER -in yourdomain.der -outform PEM -out yourdomain.crt
```

Use the following command to convert a DER encoded private key into a PEM encoded private key:

```bash
openssl rsa -inform DER -in yourdomain_key.der -outform PEM -out yourdomain.key
```

#### Convert CER to PEM

```bash
openssl x509 -in cert.cer -out cert.pem
Convert PEM to DER
```

#### Convert PEM to DER

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

#### Convert CRT to DER<br>

Use the following command to convert a PEM encoded certificate into a DER encoded certificate:

```bash
openssl x509 -inform PEM -in yourdomain.crt -outform DER -out yourdomain.der
```

Use the following command to convert a PEM encoded private key into a DER encoded private key:

```bash
openssl rsa -inform PEM -in yourdomain.key -outform DER -out yourdomain_key.der
```

#### Convert PEM to P7B

```
 openssl crl2pkcs7 -nocrl -certfile certificate.cer -out certificate.p7b -certfile CACert.cer 
```

#### Convert CRT to PEM

```bash
openssl x509 -inform DER -outform PEM -in my_certificate.crt -out my_certificate.pem
```

PEM format:

```bash
openssl rsa -inform PEM -in /tmp/ssl.key
```

Check to see if your Certificate is in PEM format:

```bash
openssl x509 -inform PEM -in /tmp/certificate.crt
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.arkannis.net/os/linux/openssl/openssl-cert-conversion.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
