Skip to content

Commit

Permalink
raise a better error if the auth headers cant be parsed as reported in
Browse files Browse the repository at this point in the history
  • Loading branch information
mwrock committed Jul 7, 2016
1 parent 2b18311 commit dffce9c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/winrm/http/transport.rb
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,12 @@ def init_auth
@logger.debug 'Sending HTTP POST for Negotiate Authentication'
r = @httpcli.post(@endpoint, '', hdr)
verify_ssl_fingerprint(r.peer_cert)
itok = r.header['WWW-Authenticate'].pop.split.last
auth_header = r.header['WWW-Authenticate'].pop
unless auth_header
msg = "Unable to parse authorization header. Headers: #{r.headers}\r\nBody: #{r.body}"
raise WinRMHTTPTransportError.new(msg, r.status_code)
end
itok = auth_header.split.last
binding = r.peer_cert.nil? ? nil : Net::NTLM::ChannelBinding.create(r.peer_cert)
auth3 = @ntlmcli.init_context(itok, binding)
{ 'Authorization' => "Negotiate #{auth3.encode64}" }
Expand Down

0 comments on commit dffce9c

Please sign in to comment.