Net::HTTP using SSL certificate


I’m attempting to login to a URL over SSL using Net:HTTP.

CERT_FILE = ‘cert.pem’
http =', 443)
http.use_ssl = true

http.cert = )
http.key = )
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

path = ‘/login.form’

response, body =, data, headers)

puts “Code = #{response.code}”
puts “Message = #{response.message}”
puts “Body= #{body}”

but I get the following error message:

C:/rubydev/olb/olb.rb:59:in initialize': Neither PUB key nor PRIV key:: nested asn1 error (OpenSSL::PKey::RSAError) from C:/rubydev/olb/olb.rb:59:innew’
from C:/rubydev/olb/olb.rb:59

Does anyone have an idea of what is going on here?


On Jan 30, 9:41 pm, julianparry [email protected] wrote:

C:/rubydev/olb/olb.rb:59:in `initialize’: Neither PUB key nor PRIV
key:: nested
asn1 error (OpenSSL::PKey::RSAError)

This message is telling you that the file you passed to isn’t a key file. That is correct since the
certificate is not a key. You’ll need to pass it the private key file
that was used to create the certificate you’re using.

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