class OpenSSL::PKey::RSA
See ruby-doc.org/stdlib/libdoc/openssl/rdoc/OpenSSL/PKey/RSA.html
Public Instance Methods
to_der_pkcs8()
click to toggle source
Returns RSA
(private) key in PKCS#8 DER format.
# File lib/openssl_pkcs8_pure.rb, line 39 def to_der_pkcs8 #if public, just use x509 default output return to_der if !private? OpenSSL::ASN1::Sequence([ OpenSSL::ASN1::Integer(0), OpenSSL::ASN1::Sequence([OpenSSL::ASN1::ObjectId("rsaEncryption"),OpenSSL::ASN1::Null.new(nil)]), OpenSSL::ASN1::OctetString(to_der) ]).to_der end
to_pem_pkcs8()
click to toggle source
Returns RSA
(private) key in PKCS#8 PEM format.
# File lib/openssl_pkcs8_pure.rb, line 49 def to_pem_pkcs8 return to_pem if !private? body=RUBY_VERSION<'1.9' ? Base64.encode64(to_der_pkcs8) : Base64.strict_encode64(to_der_pkcs8).chars.each_slice(64).map(&:join).join("\n")+"\n" "-----BEGIN PRIVATE KEY-----\n"+body+"-----END PRIVATE KEY-----\n" end