Net::HTTP using SSL certificate

Discussion in 'Ruby' started by julianparry, Jan 31, 2008.

  1. julianparry

    julianparry Guest

    Hi,

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

    CERT_FILE = 'cert.pem'
    http = Net::HTTP.new('dev.company.com, 443)
    http.use_ssl = true

    http.cert = OpenSSL::X509::Certificate.new( File.read(CERT_FILE) )
    http.key = OpenSSL::pKey::RSA.new( File.read(CERT_FILE) )
    http.verify_mode = OpenSSL::SSL::VERIFY_NONE

    path = '/login.form'

    response, body = http.post(path, 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:in `new'
    from C:/rubydev/olb/olb.rb:59

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

    Thanks,
    Jules
     
    julianparry, Jan 31, 2008
    #1
    1. Advertisements

  2. julianparry

    yermej Guest

    On Jan 30, 9:41 pm, julianparry <> 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
    OpenSSL::pKey.new 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.
     
    yermej, Jan 31, 2008
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alphonse Giambrone

    SSL Folder Location Using shared Certificate

    Alphonse Giambrone, Nov 26, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    437
    Alphonse Giambrone
    Nov 26, 2004
  2. =?Utf-8?B?QWxpZW4yXzUx?=
    Replies:
    1
    Views:
    536
    =?Utf-8?B?QWxpZW4yXzUx?=
    Sep 17, 2005
  3. John Nagle
    Replies:
    11
    Views:
    820
    =?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=
    Dec 14, 2006
  4. Aung
    Replies:
    2
    Views:
    556
    Norman Headlam
    Oct 23, 2003
  5. Mfenetre
    Replies:
    11
    Views:
    2,228
    Joe Kaplan \(MVP - ADSI\)
    Oct 12, 2005
  6. Trevor Fritz
    Replies:
    2
    Views:
    265
    Feroze [MSFT]
    May 11, 2004
  7. Keith Fahlgren
    Replies:
    3
    Views:
    231
  8. Replies:
    0
    Views:
    170
Loading...