To convert a .pem file into separate .crt (certificate) and .key (private key) files, you can use the openssl command-line tool. Here's how to do it:
Step 1: Understand the .pem File
A .pem file may contain several elements, such as:
- The private key.
- The public certificate.
- The certificate chain (optional).
Typically, the private key and public certificate are stored in the .pem file.
Step 2: Extract the Private Key
To extract the private key from the .pem file:
in yourfile.pem: The input.pemfile.out private.key: The output file for the private key.
Step 3: Extract the Certificate
To extract the certificate from the .pem file:
in yourfile.pem: The input.pemfile.out certificate.crt: The output file for the certificate.
Summary of Commands
Extract private key:
Extract certificate:
Example
If your .pem file is named combined.pem, you can use the following commands:
Extract the private key:
Extract the certificate:
Explanation
- private.key: This file contains the private key extracted from the
.pemfile. - certificate.crt: This file contains the public certificate extracted from the
.pemfile.
Now, you have your private key in private.key and your certificate in certificate.crt. These files can be used as needed, for instance, in web server configurations or other services requiring separate certificate and key files.