Reading pem file in ruby on rails

hi,
i have a certificate file in pem format. i need to read the pem file.
Need help on how to read the certificate in ruby on rails

Thanks

On Aug 24, 7:15 am, Sreevarshini K. [email protected]
wrote:

hi,
i have a certificate file in pem format. i need to read the pem file.
Need help on how to read the certificate in ruby on rails

The ruby openssl library can do that - it’s basically a straight
mapping of the openssl library.

Fred

Frederick C. wrote:

On Aug 24, 7:15�am, Sreevarshini K. [email protected]
wrote:

hi,
i have a certificate file in pem format. i need to read the pem file.
Need help on how to read the certificate in ruby on rails

The ruby openssl library can do that - it’s basically a straight
mapping of the openssl library.

Fred

Hi Fred,
thanks for the reply. i am already using open SSL library, can you help
me with any example or code snippet on how to read the pem file in ruby?

Thanks

On Aug 25, 5:16 am, Sreevarshini K. [email protected]
wrote:

Frederick C. wrote:

Hi Fred,
thanks for the reply. i am already using open SSL library, can you help
me with any example or code snippet on how to read the pem file in ruby?

You should be able to do something like
OpenSSL::X509::Certificate.new(File.read(path_to_certificate))
(OpenSSL::PKey::RSA.new(File.read(path_to_key)) if it’s just a key in
the pem file)

Fred

Sreevarshini K. wrote:

Frederick C. wrote:

On Aug 25, 5:16�am, Sreevarshini K. [email protected]
wrote:

Frederick C. wrote:

Hi Fred,
thanks for the reply. i am already using open SSL library, can you help
me with any example or code snippet on how to read the pem file in ruby?

You should be able to do something like
OpenSSL::X509::Certificate.new(File.read(path_to_certificate))
(OpenSSL::PKey::RSA.new(File.read(path_to_key)) if it’s just a key in
the pem file)

Fred

Hi Fred,
I did the same with the follwing line of code, but i am getting
“certificate verify failed” error

Code snippet:
cert = File.read(“sdk-seller_cert_key.pem”)
pem = File.read(“sdk-seller.pem”)
http.use_ssl = true
http.cert = OpenSSL::X509::Certificate.new(cert)
http.key = OpenSSL::PKey::RSA.new(pem)
http.verify_mode = OpenSSL::SSL::VERIFY_PEER

Where am i going wrrong?

Thanks

Hi,
any work arround for this issue?

Thanks

Frederick C. wrote:

On Aug 25, 5:16�am, Sreevarshini K. [email protected]
wrote:

Frederick C. wrote:

Hi Fred,
thanks for the reply. i am already using open SSL library, can you help
me with any example or code snippet on how to read the pem file in ruby?

You should be able to do something like
OpenSSL::X509::Certificate.new(File.read(path_to_certificate))
(OpenSSL::PKey::RSA.new(File.read(path_to_key)) if it’s just a key in
the pem file)

Fred

Hi Fred,
I did the same with the follwing line of code, but i am getting
“certificate verify failed” error

Code snippet:
cert = File.read(“sdk-seller_cert_key.pem”)
pem = File.read(“sdk-seller.pem”)
http.use_ssl = true
http.cert = OpenSSL::X509::Certificate.new(cert)
http.key = OpenSSL::PKey::RSA.new(pem)
http.verify_mode = OpenSSL::SSL::VERIFY_PEER

Where am i going wrrong?

Thanks

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs