Feature #1257

Handle encypted CA/Certificate private keys

Added by Brad Langhorst over 9 years ago. Updated 10 months ago.

Pull Request Review
Target version:
Start date:
Due date:
% Done:


Estimated time:


when i export a certificate using

i get an empty file.

the private key downloads just fine.


#1 Updated by Brad Langhorst over 9 years ago

upon further investigation, i see that the crt was not saved.

here's a bit of the config file.


#2 Updated by Brad Langhorst over 9 years ago

the title of this bug should be "certificate file is not properly generated or saved." using internal cert auth

#3 Updated by Jim Pingle over 9 years ago

  • Status changed from New to Rejected

I can't replicate this - I can make certificates several different ways on current snapshots and they are complete inside of the config.

You might want to make a thread on the forum with more detail about exactly how you are creating the certificates, there may be something else going on, but the certificate generation code appears to be working properly.

#4 Updated by Brad Langhorst over 9 years ago

Seems to be related to importing of a certificate authority.

To isolate a bit... I created an internal certificate authority and generated a cert.
This one looks fine.

I still cannot create certs when i choose the pre-existing cert authority that I created outside of pfsense
(using openssl/tinyca2)

I looked for some kind of log to show what commands php is trying to run, but didn't find one.
How can i help debug this problem?

#5 Updated by Jim Pingle over 9 years ago

When you imported the CA, did you import both the cert and private key of the CA?

All of the certificates are made in The code is laid out pretty well there, shouldn't be hard to see what commands are run.

#6 Updated by Brad Langhorst over 9 years ago

One more clarification...
I just checked and see that the private key is encrypted, so cert signing must fail since it never asks for a password.

I can think of a few possible solutions
  • ask for a password before attempting to sign a new cert (my favorite option)
  • don't allow encrypted private keys (probably not a great idea), and reject an invalid key during import
  • don't allow creation of new certs if no usable key is available for the selected cert

Certificate generation works if I paste in the unencrypted ca key, though this strikes me as a poor security practice.
At minimum, I think the user should be notified if the a new cert cannot be generated.

#7 Updated by Jim Pingle over 9 years ago

  • Subject changed from exported certificate files are empty to Handle encypted CA private keys
  • Status changed from Rejected to New
  • Target version deleted (2.0)
  • Affected Architecture All added
  • Affected Architecture deleted ()

Not sure if this will make 2.0 or not. It may have to wait for 2.1 at this point, it may end up a documented limitation for 2.0 because it works fine for certificates made and managed in the GUI.

#8 Updated by Chris Buechler about 4 years ago

  • Tracker changed from Bug to Feature

#9 Updated by Peter Feichtinger over 1 year ago

I made a preliminary PR that adds support for encrypted private keys to the CA, certificate, and user managers.
Would love to get some feedback:

#10 Updated by Jim Pingle 11 months ago

  • Subject changed from Handle encypted CA private keys to Handle encypted CA/Certificate private keys

#11 Updated by Jim Pingle 10 months ago

  • Status changed from New to Pull Request Review
  • Target version set to 2.5.0

Also available in: Atom PDF