1

I have a .pem file which contains both my certificate and encrypted private key, ie:

Bag Attributes
....
-----BEGIN CERTIFICATE-----
....
-----END CERTIFICATE-----
Bag Attributes
....
-----BEGIN ENCRYPTED PRIVATE KEY-----
....
-----END ENCRYPTED PRIVATE KEY-----

And I need to instead have a .pem file containing both the certificate and the decrypted private key. How can I achieve this on linux, preferrably utilising the openssl application?

3

To decrypt a private key from a pem file you would do something like this with a subcommand (rsa pkcs8, pkcs12):

openssl rsa -in inputfilename -out outputfilename

Your input file is different because you concatenated both keys in one file. But you can simple edit the pem file to split it in 2 files.

  • I think you need a subcommand in there. Maybe pkey? Please @ me when you fix it and I'll remove my downvote. – Spiff Mar 21 '18 at 19:51
  • Yes, it should be pkey for new format keys (PKCS8) or rsa for the older PKCS1. – grawity Mar 21 '18 at 21:59
  • Added suggestion of @Spiff – bbaassssiiee Mar 24 '18 at 8:09
  • To do it without editing: openssl x509 <in >out; openssl pkey <in >>out – dave_thompson_085 Mar 24 '18 at 10:04

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.