Google Answers Logo
View Question
 
Q: Trouble converting an RSA private key. ( No Answer,   11 Comments )
Question  
Subject: Trouble converting an RSA private key.
Category: Computers > Programming
Asked by: yarbles-ga
List Price: $25.00
Posted: 10 Jul 2004 16:35 PDT
Expires: 13 Jul 2004 12:01 PDT
Question ID: 372461
So an employee of mine purchased an SSL certificate and misplaced the
RSA private key used to generate the CSR.

He still has the TXT version of the key and we need to convert it to
PEM format so apache can read it.

I'm looking for a way to convert the TXT version of the key to PEM
format.  The openssl program does not seem to have a conversion
mechanism of this sort.

Details:

1)  We have the private key in this format:

Private-Key: (1024 bit)
modulus:
    00:ad:c1:43:d8:5f:14:eb:bb:94:7c:05:b3:e5:fc:
....


If anyone can figure out how to do this, you will save the day!
Answer  
There is no answer at this time.

Comments  
Subject: Re: Trouble converting an RSA private key.
From: crythias-ga on 10 Jul 2004 16:41 PDT
 
isn't PEM text format anyway?
http://www.mkssoftware.com/docs/man1/openssl_dsa.1.asp

(I mean, can you read it? with cat/emacs/vim?) (make and open a copy)
Subject: Re: Trouble converting an RSA private key.
From: crythias-ga on 10 Jul 2004 16:49 PDT
 
Please ignore the previous comment.
Subject: Re: Trouble converting an RSA private key.
From: crythias-ga on 10 Jul 2004 17:00 PDT
 
Actually, I may not be so stupid, is there a section
-----BEGIN RSA PRIVATE KEY-----
........
-----END RSA PRIVATE KEY-----

In your output file?
It is the same thing as what your .pem should be.
Subject: Re: Trouble converting an RSA private key.
From: crythias-ga on 10 Jul 2004 17:04 PDT
 
I tried the above on my own. Of course, I do recommend you back up any
.pem's before overwriting them.

Also, the text file you mentioned must have been generated with a
command like openssl rsa -in privkey.pem -text -out outfile.txt
Subject: Re: Trouble converting an RSA private key.
From: yarbles-ga on 10 Jul 2004 20:54 PDT
 
Exactly, the file that I have was the output of 

openssl rsa -in privkey.pem -text -out outfile.txt

I need a way to get that outfile.txt back to PEM format.  No luck
finding this out on my own yet.

Thanks for the posting!
Subject: Re: Trouble converting an RSA private key.
From: crythias-ga on 10 Jul 2004 21:26 PDT
 
I don't think you understand what I said above, the part that has
-----BEGIN RSA PRIVATE KEY-----
........
-----END RSA PRIVATE KEY-----
in your txt file *IS* the .pem 
copy and paste that part into a file filename.pem. That's your key.
Subject: Re: Trouble converting an RSA private key.
From: yarbles-ga on 10 Jul 2004 21:41 PDT
 
There is no

-----BEGIN RSA PRIVATE KEY-----
........
-----END RSA PRIVATE KEY-----

in the file.  The employees, for some reason, saved everything above that
portion of the output.  I know this is really stupid but it's what we're
stuck with.

For clarification, I will paste similar output below (different private key),
same printout format.  I need to get from that format to the format above.


Private-Key: (1024 bit)
modulus:
    00:bb:f8:0b:0a:fd:59:12:5b:ef:57:f1:cc:66:b3:
    5c:d3:fd:9f:dc:61:82:b3:51:40:d4:ab:cb:73:d3:
    72:d9:e3:7e:77:08:a1:1f:75:b4:18:0e:ca:b1:ce:
    d6:6a:2a:57:40:e1:ce:2b:7d:e1:51:c6:71:92:9c:
    e6:94:b4:b7:cd:16:25:73:0f:d3:00:fb:06:b5:bf:
    1b:b7:2a:ce:13:46:12:5d:b0:de:49:fd:1e:96:a7:
    3d:26:83:70:32:58:75:5f:26:e1:95:cd:99:4c:d9:
    22:9f:9d:35:89:fa:df:2b:16:cb:e1:14:b1:08:0d:
    5d:97:b3:32:3b:cd:3d:52:cd
publicExponent: 65537 (0x10001)
privateExponent:
    00:82:2a:db:3a:d9:06:fd:b7:bc:9f:62:4a:f2:33:
    f3:6c:ba:8e:21:c7:45:03:78:99:34:ad:63:4e:ea:
    76:f6:7c:9b:ef:42:82:91:8e:a9:10:9f:ed:ae:04:
    56:67:5e:ba:dd:ab:81:62:8c:e1:a4:07:90:4e:bf:
    68:ce:41:f7:a5:56:1a:49:e0:c9:7b:10:50:d6:34:
    85:2d:71:96:a5:36:53:f7:23:57:0b:91:a9:e3:64:
    34:d6:e7:00:04:ac:b8:bb:31:99:43:64:11:13:c3:
    d0:0a:97:ab:7a:2c:d0:e3:df:30:ca:5c:cf:67:77:
    46:be:03:01:42:08:df:b1:e1
prime1:
    00:e7:44:ed:0a:cc:e4:92:6a:f5:49:d2:b7:d1:cf:
    97:be:7c:89:11:1e:bb:39:cb:5d:43:51:0c:fc:0f:
    1c:21:b0:ff:56:f5:1b:06:4d:e5:91:38:aa:ce:c9:
    56:43:8d:27:8e:1f:c8:9d:76:5a:38:93:9d:7a:44:
    6f:17:17:f6:6f
prime2:
    00:d0:11:c1:91:92:91:0c:9e:9a:62:fd:72:05:14:
    ea:bc:bc:b2:c8:8d:6d:c5:98:82:5e:af:b4:1b:e5:
    26:63:2f:8c:90:68:01:ac:de:e0:53:94:7f:1e:88:
    42:8f:97:98:22:2a:2b:40:6f:ad:91:61:7b:17:ac:
    d5:b9:85:48:83
exponent1:
    5e:09:50:b9:4b:86:c5:62:68:4a:94:3b:da:3c:26:
    df:75:93:e6:3a:30:b6:d7:52:1c:c5:20:1a:7d:aa:
    5a:a8:b5:aa:8e:0f:67:08:d5:87:af:1b:04:ea:29:
    01:5e:ab:ee:c6:4d:b4:79:23:46:4d:ff:82:6f:c1:
    1c:0a:ca:51
exponent2:
    00:9d:97:b5:4a:f2:fe:15:d6:d3:0c:82:f6:27:4f:
    2e:74:01:60:50:72:7e:60:19:21:35:62:53:42:85:
    8f:4b:b4:a9:fc:7e:2a:36:ab:20:b1:6d:59:d2:e0:
    55:b9:b8:92:2b:de:50:a0:1f:76:11:15:0a:4c:66:
    46:02:9c:26:cd
coefficient:
    35:58:bf:14:30:7f:08:d1:b1:91:8c:19:a2:eb:02:
    e6:af:74:3c:4e:ff:60:1c:21:e8:30:c5:ef:2c:06:
    28:e4:46:6b:2d:6d:70:a7:d7:40:d7:fc:75:14:4f:
    88:e7:f2:be:da:95:02:eb:ca:aa:81:12:cb:7e:53:
    d5:13:a2:ca
Subject: Re: Trouble converting an RSA private key.
From: crythias-ga on 10 Jul 2004 23:28 PDT
 
And I guess it's too much to hope you actually had a backup on tape or
something... :) if you use the -noout command, it doesn't append the
RSA private key...

Here's an interesting "Google Groups" post... but I don't know what to
*do* with it... http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&threadm=aidbli%24kc%241%40FreeBSD.csie.NCTU.edu.tw&rnum=6&prev=/groups%3Fq%3Dconvert%2520rsa%2520text%2520key%2520to%2520pem%26hl%3Den%26lr%3D%26ie%3DUTF-8%26sa%3DN%26tab%3Dwg

Here's another stab...
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&threadm=pan.2002.04.13.20.44.44.148187.11081%40wanadoo.fr&rnum=1&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3DUTF-8%26q%3Dconvert%2Brsa%2Bmodulus%2Bto%2Bpem%26btnG%3DSearch

I think there is hope, but I personally don't know what to say. There
is someone in those two links who actually could do it and fixed their
situation, so it's not all lost.
Subject: Re: Trouble converting an RSA private key.
From: yarbles-ga on 12 Jul 2004 11:30 PDT
 
That's the solution!  Thank you so much.  I built a small c program from the
example on this page:

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&threadm=aidbli%24kc%241%40FreeBSD.csie.NCTU.edu.tw&rnum=6&prev=/groups%3Fq%3Dconvert%2520rsa%2520text%2520key%2520to%2520pem%26hl%3Den%26lr%3D%26ie%3DUTF-8%26sa%3DN%26tab%3Dwg

And I was able to get the PEM format of the key generated.  So how can I get you
the credit for answering this?
Subject: Re: Trouble converting an RSA private key.
From: crythias-ga on 12 Jul 2004 12:29 PDT
 
I am not a Google Answers Researcher :) Your success is my reward (TM) :).

(To know a GA Researcher, their username is hyperlinked.)
Subject: Re: Trouble converting an RSA private key.
From: crythias-ga on 12 Jul 2004 19:12 PDT
 
PS :) You may desire to cancel the question :)

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy