From: Tuj www Date: 2012-09-20T01:25:49+09:00 Subject: net-https error on x509 certs Hello, I am trying to send a GET request to a https URL which requires passing certificate, key and ca certificate to authenticate and getting below error: /usr/lib/ruby/1.8/net/http.rb:567:in `initialize': can't convert OpenSSL::X509::Certificate into String (TypeError) from /usr/lib/ruby/1.8/net/http.rb:567:in `new' from /usr/lib/ruby/1.8/net/http.rb:567:in `connect' from /usr/lib/ruby/1.8/net/http.rb:553:in `do_start' from /usr/lib/ruby/1.8/net/http.rb:542:in `start' from tp2:18 Code: #!/usr/bin/ruby require 'net/https' require 'openssl' server = "serverdomainname" crt = File.read "crtfile" ca = File.read "cafile" key = File.read "keyfile" uri = URI.parse("https://#{server}:8140") session = Net::HTTP.new(uri.host, uri.port) session.use_ssl = true session.verify_mode = OpenSSL::SSL::VERIFY_NONE session.ca_file = OpenSSL::X509::Certificate.new ca session.cert = OpenSSL::X509::Certificate.new crt session.key = OpenSSL::PKey::RSA.new key res = session.start do |http| http.get("/v1") end OpenSSL reads the certificate properly, format is pem, but net-https gives error. -Tuj -- Posted via http://www.ruby-forum.com/.