net-http-digest_auth icon indicating copy to clipboard operation
net-http-digest_auth copied to clipboard

HTTPS support

Open dsoronda opened this issue 11 years ago • 6 comments

I got this error when I'm trying to get response from HTTPS url (ie uri = URI.parse 'https://localhost:8000/')

/usr/local/rvm/gems/ruby-2.1.1@rails4/gems/net-http-digest_auth-1.4/lib/net/http/digest_auth.rb:87:in `auth_header': undefined method `gsub' for nil:NilClass (NoMethodError)
        from file.rb:22:in `<main>'

dsoronda avatar Jan 14 '15 20:01 dsoronda

What are you sending as the WWW-Authenticate header?

drbrain avatar Jan 14 '15 22:01 drbrain

puts res['www-authenticate']
auth = digest_auth.auth_header uri, res['www-authenticate'], 'GET'

puts returns :

negotiate, digest nonce="636581428587179706342730467643667776813115625137678420954", realm="someserver.com", algorithm="md5"

dsoronda avatar Jan 15 '15 08:01 dsoronda

Does this raise an exception?

drbrain avatar Jan 15 '15 22:01 drbrain

I'm sorry, but I'm still new with Ruby. I tried this :

begin
    auth = digest_auth.auth_header uri, res['www-authenticate'], 'GET'
rescue Exception => msg  
  puts msg  
end

and result is:

undefined method `gsub' for nil:NilClass

dsoronda avatar Jan 16 '15 08:01 dsoronda

Ok. The problem is with the "negotiate" option in the header. Until I fix your bug you can strip it before calling auth_header

drbrain avatar Jan 16 '15 16:01 drbrain

This is fixed by #16.

paulvt avatar Mar 15 '18 09:03 paulvt