
This assumes that you have already installed OpenSSL on your system.
Before creating a PEM file that contains both a private key and one or more public certificates, you will first need to create the public certificates and private key. These articles describe how to create the public certificates and private key.
- Create private key
- Create RSA public certificate
- Create DSA public certificate
- Create ECDSA public certificate
Let's say you've created the following files:
- foo.crt (public certificate)
- foo.key (private key)
The cat command (on Linux) can be used to create the PEM file.
AVOID TROUBLE
The order here is important. The public certificates must be listed first and the private key listed last.
In this example, foo.pem will contain both the foo.crt public certificate and foo.key private key.
cat foo.crt foo.key > foo.pem
The cat command can be used to verify that the PEM file contains both the public certificate and private key.
cat foo.pem
Something like this should be returned.
-----BEGIN CERTIFICATE-----
MIIDTDCCAjQCCQD7guN49Lc+BzANBgkqhkiG9w0BAQ0FADBoMQswCQYDVQQGEwJV
UzELMAkGA1UECAwCV0kxETAPBgNVBAcMCEFwcGxldG9uMQ8wDQYDVQQKDAZGcmVl
S0IxDzANBgNVBAsMBkZyZWVLQjEXMBUGA1UEAwwOd3d3LmZyZWVrYi5uZXQwHhcN
-----END CERTIFICATE-----
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEAnyXbqz7ieuzL6sa3iM13eux4bitjKbX7QmYCjM/ue3t0TFAI
FP3SuhUUcXLjzy72nfNnt8oi9BZJg2VQgiJkE5ZcwCXjxxjIzFXYVVRUkBStVmg5
7sy5dUGTl8IMH2AvHamOdgOeszZIQdBUZj9z33QlehdbEhx5N4Ae5Vymzx0VK+Fe
-----END RSA PRIVATE KEY-----
Did you find this article helpful?
If so, consider buying me a coffee over at