jruby-openssl

openssl equivalent command in ruby

大城市里の小女人 提交于 2020-01-13 07:00:12
问题 I have to convert certificate file(pem format) into pfx using private key. The command perfectly works in linux is openssl pkcs12 -export -out certificate1.pfx -inkey myPrivateKey.key -in myCert.pem Can anyone help me to write equivalent code in ruby using ruby-openssl. 回答1: 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

openssl equivalent command in ruby

大憨熊 提交于 2019-12-04 19:25:56
I have to convert certificate file(pem format) into pfx using private key. The command perfectly works in linux is openssl pkcs12 -export -out certificate1.pfx -inkey myPrivateKey.key -in myCert.pem Can anyone help me to write equivalent code in ruby using ruby-openssl. 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