I am working with a security person that baffles me a bit with the practices he performs. Besides the issue of this person insisting on bypassing every security measure in place we have got into it about handling private keys and certificates.

So this is my perspective of best practices in regards to web servers: When generating private keys it is best to generate them where they will be used and never move them to any other system, if at all possible. From this point generate a CSR from the server with it, to get a signed certificate. At this point the private key is never exposed to anything but the server that originally generated it, therefore there is no chance a hacked laptop or share might expose it.

This makes sense to me, however this security person seems to prefer generating the private key on a system he controls, then transfer this to whatever system needs it. This seems to extend the risk by having the private key in more then one spot as well as a lot more work with no benefit that I can see.

Am I missing anything with this? Other than common practice, is there a reason I am not seeing for this to be done?

  • The public/private key pair should be generated on the system that uses it. A CSR should be generated using its public key, and the public key is signed by the CA. The private key should not be involved in any CSR, or transfer.
    – RoraΖ
    Feb 25, 2015 at 17:17

2 Answers 2


As long as the machine in question has enough entropy to generate strongly random keys and nonces, that's totally correct. The key must never leave that server. Even more, if I were working on a critical application, I wouldn't even trust that machine and keep the key in a HSM. It might cost a lost, but it significantly enhances the security.

There is a broad spectrum of security practices, going from the best case above, to the worst possible situation, which appears to be your case. Either your colleague has a specific reason for doing so or he/she is putting the security of your applications at risk. Immediately confront him/her. If I were in charge, I would fire that "security" person at once.

  • Thanks for the information. It is as I suspected but I always like to double check myself. Unfortunately I do not have the power to do anything except accept things as they are. Feb 25, 2015 at 17:59

If you are generating keys and immediately putting them into service then generating them on the server is generally a perfectly reasonable thing to do.

Having said that I can think of several reasons you might want to generate keys on a box other than the one that will use them.

  1. You may want to have a backup copy of the key so you do not need to get a new certificate if your servers disks fail and you have to rebuild it.
  2. If you use "http key pinning" then you can't put keys into service as soon as you generate them. You must generate one or more spare keys in advance so they can be advertised in the key pins. These spare keys should be kept in a secure location (ideally off-line) until they are needed.
  3. You may have more confidence in the random number generator on a physical box used for key generation than on a VM, especially a freshly spooled up VM.
  4. You may want to use the same certificate and hence the same key on multiple servers.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .