[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

saving a OpenSSL::X509::Certificate as PKCS#12?

Magnus Bodin

3/17/2005 4:48:00 PM


I want to create a X.509 certificate and save it as PKCS#12.
All in pure Ruby.

I've looked in the WEBrick and QuickCert sources, waded through
sources of openssl, stunnel and now ruby-1.8.2, but it is a little bit
hazy.

My guess is that I shall create a PKCS12-object of some sort and
initialize this with my already created X.509-cert, right?

How do I save it in PKCS#12-format, readable from e.g. firefox?

I've successfully created a cert and saved it as PEM with the
OpenSSL::X509::Certificate#to_pem, and then *converted* it on the
commandline with the openssl-tool. But I'd like to save it in the right
format directly from ruby.

Please advise or even better:
Please point me to the fine manual, because I cannot find it.

-- magnus


3 Answers

Magnus Bodin

3/19/2005 2:10:00 PM

0

On Fri, Mar 18, 2005 at 01:48:15AM +0900, Magnus Bodin wrote:
>
> I want to create a X.509 certificate and save it as PKCS#12.
> All in pure Ruby.

I guess I can't?
I guess I have to save it as PEM and then do a
'openssl pkcs12 -inkey mykey.pem -in mycert.pem -out mypair.p12 -export'

?

The sillyness in this is that I will lose simplicity on the
win32 platform as I just want to install the one-click-installer. It
includes the openssl-libraries, but not the commandline tool. A pure
ruby totally independent solution would be much, much nicer.

-- magnus


GOTOU Yuuzou

3/19/2005 4:21:00 PM

0

Magnus Bodin

3/20/2005 9:29:00 PM

0

On Sun, Mar 20, 2005 at 01:21:22AM +0900, GOTOU Yuuzou wrote:
>
> p12 = OpenSSL::PKCS12.create("passwd", "FriendlyName", pkey, cert)
> print p12.to_der

Thanks. This worked perfectly!

-- magnus