Openssl equivalent command in ruby
1 answer
It should be easy :
#!/usr/bin/env ruby
# export-der.rb
require 'openssl'
def export_der(pass, key, cert, out)
key = OpenSSL::PKey.read File.read(key)
cert = OpenSSL::X509::Certificate.new File.read(cert)
name = nil # not sure whether this is allowed
pkcs12 = OpenSSL::PKCS12.create(pass, name, key, cert)
File.open(out, 'w'){|f| f << pkcs12.to_der }
end
puts 'Password:'
export_der($stdin.read, *ARGV)
And call it like this (untested; -)):
$ ruby export-der.rb myPrivateKey.key myCert.pem certificate1.pfx
+4
source to share