To create a .pem file from a .key (private key) and a .crt (certificate) file, you need to combine them into a single .pem file. Here's how you can do it:
Step 1: Understand the Files
- .key file: This is your private key, usually generated when you create a Certificate Signing Request (CSR).
- .crt file: This is your SSL certificate, which might be issued by a Certificate Authority (CA) or self-signed.
Step 2: Combine the .key and .crt Files into a .pem File
You can simply concatenate the .key and .crt files to create a .pem file using the cat command in the terminal:
cat your_certificate.crt your_private.key > combined_certificate.pem
Example
If your files are named server.crt and server.key, you would use:
cat server.crt server.key > server.pem
Explanation
cat server.crt server.key: Concatenates the contents ofserver.crtandserver.key.> server.pem: Redirects the concatenated output into a new file calledserver.pem.
Step 3: Verify the .pem File (Optional)
You can verify the contents of the .pem file to ensure that it includes both the certificate and the private key:
openssl x509 -in server.pem -text -noout
This command will display the contents of the certificate part of the .pem file.
Summary
The resulting .pem file will contain both your private key and certificate, and it can be used in applications that require a .pem format, such as certain web servers or other SSL/TLS implementations.