Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert certificates/keys between different formats #5

Open
aslafy-z opened this issue Apr 11, 2022 · 3 comments
Open

Convert certificates/keys between different formats #5

aslafy-z opened this issue Apr 11, 2022 · 3 comments

Comments

@aslafy-z
Copy link

Thank you for your work on this project!
I'd love to see the following new feature in the CLI:

Ability to convert certificates/keys between PEM to PKCS12 (with password support), and the other way around.

@yakuter
Copy link
Owner

yakuter commented Apr 11, 2022

Hello @aslafy-z Thanks for mentioning about the issue. I can work on it but I need to understand it well. Can you give an example with openssl command about this conversion?

@yusufozturk
Copy link

yusufozturk commented Jun 21, 2022

@yakuter we also need to convert pfx to cert.pem and cert.key.

Here is the openssl doc to do that:

Conversion to a combined PEM file

To convert a PFX file to a PEM file that contains both the certificate and private key, the following command needs to be used:
openssl pkcs12 -in filename.pfx -out cert.pem -nodes

Conversion to separate PEM files

We can extract the private key form a PFX to a PEM file with this command:
openssl pkcs12 -in filename.pfx -nocerts -out key.pem

Exporting the certificate only:
openssl pkcs12 -in filename.pfx -clcerts -nokeys -out cert.pem

Removing the password from the extracted private key:
openssl rsa -in key.pem -out server.key

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants