May sound like a silly question but where are private keys stored as part of Asymmetric Encryption?

For example say I have a Web Server and I install a 3rd Party SSL certificate from a third party. When installed the certificate is presented to end users to verify the identity of the Web Server and the public key within the certificate is used to encrypt data as part of SSL. Where does the Web Server normally keep the corresponding Private Key to decrypt the data and how is this kept safe? Would they be in "key stores"?

closed as too broad by forest, Tom K., Overmind, Jeroen - IT Nerdbox, Xander Jun 9 '18 at 20:38

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    It depends primarily on operating system and particular application. That's all we can tell based on your input. – Crypt32 Jun 4 '18 at 16:18

In addition to the other answers, which cover storing the private key within the server; you should also be aware that private keys can be stored outside of your server in a specialist appliance called a Hardware Security Module (HSM). This is often the case in high security environments where the cost of a breach far outweighs the relatively high cost of the HSM.

The private key is stored in the HSM and never leaves the appliance un-encrypted. Any cryptographic activity that involves the private key is carried out internally within the device. HSMs communicate with the servers using either standards compliant protocols or, with drivers installed on the servers, using vendor specific protocols.

In order to maximize the ROI, many HSMs can be purchased as network enabled appliances; which can be shared between many servers and therefore distribute the cost.

If not network enabled, most connect to a single server via USB; or internally as a PCI card.

  • Would the webserver then have to create an encrypted connection with the HSM in order to retrieve the private key safely? – deltzy Jun 5 '18 at 17:40
  • The webserver doesn't retrieve the private key. The webserver sends the data to the HSM for signing or encryption and receives the data (signed or encrypted) back. The private key never leaves the HSM. – garethTheRed Jun 5 '18 at 20:09

Depends on the web server and the operating system, for example:

  1. The Apache web server on Linux would store these in flat files in a dedicated directory, which is distribution-dependent, e.g. /etc/apache2/ssl. You can choose a custom path in your virtual host definition, so the path/location is more of a convention rather than a standard or a requirement.

  2. Apache Tomcat, for example, uses a key store, which is encrypted using a symmetric key, and typically the specific SSL/TLS configuration file will contain the key store password.

  3. IIS on Windows may use a variety of certificate stores, most of which are physically located in the Windows registry.

As you can tell, the implementation varies from one platform to another - from flat files, through an encrypted database-like file, down to an OS-provided/managed specialized certificate store.

I hope this helps.

  • Tomcat traditionally had a choice between the Java SSL/TLS stack (JSSE) using a keystore, or the 'APR' stack (OpenSSL) using PEM files. As of 8.5 in 2016, they merged this config so that any stack can use either kind of files. – dave_thompson_085 Jun 5 '18 at 6:54

As @Crypt32 mentioned, your question is overly broad as it doesn't specify an application or system.

In general, private keys are highly sensitive and need to be stored securely. Anyone with a copy of your private key could impersonate you successfully. That means you need to carefully lock down all access to the file. The private key file itself should be encrypted, with the decryption key separate from the encrypted file, and the storage of the decryption key should also be secured.

If you're dealing with Apache, Tomcat, or other java app, it's fairly common to store the private key in an encrypted Java Key Store. Other alternatives include a PKCS#12 file, which is a more standardized (less language-specific) container format than JKS. Other servers and systems will have different needs. For example, on Windows, the private keys may be stored in the Certificate Store.

  • Where would the decryption key to the private key file be kept, and how would that be encrypted, and so on. Is it a matter of locking down access to these encrypted key files? – deltzy Jun 5 '18 at 17:50
  • One example is that passwords to Tomcat’s key stores are usually found in conf/server.xml; so access to that file needs to be controlled. Yes, you are correct. – John Deters Jun 5 '18 at 18:14

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