From dffce9cd838d728f5fa5d6c2564fefb807486f44 Mon Sep 17 00:00:00 2001 From: Matt Wrock Date: Thu, 7 Jul 2016 00:18:08 -0700 Subject: [PATCH] raise a better error if the auth headers cant be parsed as reported in #208 --- lib/winrm/http/transport.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/winrm/http/transport.rb b/lib/winrm/http/transport.rb index 63b0c917..0a4397e1 100644 --- a/lib/winrm/http/transport.rb +++ b/lib/winrm/http/transport.rb @@ -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}" }