Information Security Stack Exchange is a question and answer site for information security professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We have a set of public and private keys and certificates on the server. The problem is that while public encryption works fine, the pass phrase for the .key file was lost.

So, when trying to

openssl rsa -in the.key

it, obviously, asks for the pass phrase.

Is it possible to get the pass phrase somehow?

share|improve this question
39  
If the passphrase could be recovered, then why bother having a passphrase at all? – immibis Mar 10 at 19:57
1  
Depending on the conditions and length of your usual passphrase's you can consider brute force attacks. If you use the same variation of a passcode or a ton of different ones utilize cewl to generate your wordlist. – John Mar 11 at 2:10
1  
Yep, just try every possibility until you get guess right. – tylerl Mar 11 at 3:13
1  
@immibis To be fair, there are also things like the pdf password which is basically just a "pretty please don't do that" or password encryption schemes that have been broken for years. So all in all it's not that unreasonable to ask. – Voo Mar 11 at 13:55
up vote 39 down vote accepted

The whole point of having a passphrase is to lock out anyone who does not know it. Allowing it to be recovered would defy the principle and allow hackers who get access to your certificate to recover your keys.

So no, there is no such thing.

What you should do is declare the keys as lost to the issuer so that they revoke your certificate. Then, you have to create a new one from scratch.

share|improve this answer
8  
I think it's important to note here that many commercial CAs will allow you to (revoke and) re-issue a certificate at least a few times without additional charge. (I mention this because to my ear "from scratch" sounds like you mean "pay again.") – Calrion Mar 11 at 8:06
3  
@Calrion That depends a lot on CA of course. For example with StartCom and their free certs, revoking a cert is not free (not sure if it's because of additional work on their side or just in order to educate people not to flood fill the Certificate Revocation List). But of course this is a very different situation to a piad certificate anyway ... – Hagen von Eitzen Mar 11 at 9:25
    
@HagenvonEitzen True; that's actually the reason I no longer trust StartCom—it's impossible to determine revocation status (i.e. the difference between "cert is valid" and "subscriber couldn't/wouldn't pay for revocation.") – Calrion May 8 at 23:35

From your description, it sounds like the server is currently using the key, which means the server "knows" the pass phrase. If this is correct and you have appropriate access to the server, you should be able to extract it. How you'd do that depends on what the server software is and how it's set up.

Just as an example, if you were running Apache, and it had something like this in the httpd.conf file:

SSLPassPhraseDialog exec:/etc/apache2/getsslpassphrase

That means that Apache will run /etc/apache2/getsslpassphrase to get passphrases; and you can do the same:

sudo /etc/apache2/getsslpassphrase server.example.com:443 RSA

should output the passphrase for the server.example.com key.

For other server software (or Apache with different config options), you'd have to specify the details.

share|improve this answer
    
JBOSS does something similar where there will be an encrypted file which has the passphrase, so you can extract the file and decrypt it externally. – Coxy Mar 11 at 3:36

Under some circumstances it may be possible to recover the private key with a new password. It would require the issuing CA to have created the certificate with support for private key recovery.

This is normally not done, except where the key is used to encrypt information, e.g. when used for email or file encryption. The issuing CA should be able to tell you whether key recovery is possible, and help you re-create the key with a new password if it is.

share|improve this answer
    
interesting. I have never heard of private key recovery support. Can you provide some links that talk about this? – stochastic Mar 11 at 18:26
2  
@stochastic Here's one link, for the CA I usually work with: EJBCA key recovery. It's also mentioned in RFC 3647, which describes the standard template for CP and CPS for CAs. – Jenny D Mar 12 at 7:26

As far as our current knowledge goes, there is only brute force available. Ask the person who created the key to try to remember the passphrase and try. If this is not available, try a cracking program that generates popular passwords as a passphrase generator.

However, when the passphrase was well chosen, your chances to crack the key are minimal.

share|improve this answer
    
If the person who created the key can provide some guidelines, even if they don't remember the specific phrase it makes brute forcing it much easier. Things like "It was long. I didn't use symbols. It was a famous quote." – Bobson Mar 11 at 15:58

Just to offer an alternative view, I'd say it is most certainly possible. However, it is most probably not practical at all.

Process is known as cracking, and usually involves either a brute force attack or dictionary based one (perhaps helped with newly detected algorithm weaknesses) . Depending on complexity of passphrase used and your computing power it could take from several minutes to many billions of years, though.

So if your remember most of the words of the passphrase or if it was very short, and data it encrypts is very important to you and unobtainable otherwise - it might be worth a try. Otherwise, as others say, it's gone (unless critical algorithm weakness becomes public in following years, of course).

For the process itself if you decide it is worth a try, see for example this question

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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