Hi,

In message <20050317164756.GO18877 / bodin.org>,
 `Magnus Bodin <magnus / bodin.org>' wrote:
> I want to create a X.509 certificate and save it as PKCS#12. 
> All in pure Ruby. 

OpenSSL::PKCS12.create is a wrapper of PKCS12_create
function.

require "openssl"

pkey = OpenSSL::PKey::RSA.new(512)
cert = OpenSSL::X509::Certificate.new
cert.version = 1
cert.subject = cert.issuer = OpenSSL::X509::Name.parse("/C=FOO")
cert.public_key = pkey.public_key
cert.not_before = Time.now
cert.not_after = Time.now+3600*24*365
cert.sign(pkey, OpenSSL::Digest::SHA1.new)
p12 = OpenSSL::PKCS12.create("passwd", "FriendlyName", pkey, cert)
print p12.to_der

-- 
gotoyuzo