Class: WinRM::HTTP::HttpNegotiate
- Inherits:
-
HttpTransport
- Object
- HttpTransport
- WinRM::HTTP::HttpNegotiate
- Defined in:
- lib/winrm/http/transport.rb
Overview
NTLM/Negotiate, secure, HTTP transport
Instance Attribute Summary
Attributes inherited from HttpTransport
Instance Method Summary collapse
-
#initialize(endpoint, user, pass, opts) ⇒ HttpNegotiate
constructor
A new instance of HttpNegotiate.
- #send_request(message) ⇒ Object
Methods inherited from HttpTransport
#basic_auth_only!, #no_ssl_peer_verification!, #no_sspi_auth!, #ssl_peer_fingerprint_verification!, #verify_ssl_fingerprint, #with_untrusted_ssl_connection
Constructor Details
#initialize(endpoint, user, pass, opts) ⇒ HttpNegotiate
Returns a new instance of HttpNegotiate.
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/winrm/http/transport.rb', line 149 def initialize(endpoint, user, pass, opts) super(endpoint, opts) require 'rubyntlm' no_sspi_auth! user_parts = user.split('\\') if user_parts.length > 1 opts[:domain] = user_parts[0] user = user_parts[1] end @ntlmcli = Net::NTLM::Client.new(user, pass, opts) @retryable = true no_ssl_peer_verification! if opts[:no_ssl_peer_verification] @ssl_peer_fingerprint = opts[:ssl_peer_fingerprint] @httpcli.ssl_config.set_trust_ca(opts[:ca_trust_path]) if opts[:ca_trust_path] @httpcli.ssl_config.cert_store = opts[:cert_store] if opts[:cert_store] end |
Instance Method Details
#send_request(message) ⇒ Object
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/winrm/http/transport.rb', line 168 def send_request() ssl_peer_fingerprint_verification! init_auth if @ntlmcli.session.nil? () hdr = { 'Content-Type' => 'multipart/encrypted;'\ 'protocol="application/HTTP-SPNEGO-session-encrypted";boundary="Encrypted Boundary"' } resp = @httpcli.post(@endpoint, body(seal(), .bytesize), hdr) verify_ssl_fingerprint(resp.peer_cert) if resp.status == 401 && @retryable @retryable = false init_auth send_request() else @retryable = true decrypted_body = winrm_decrypt(resp) (decrypted_body) WinRM::ResponseHandler.new(decrypted_body, resp.status).parse_to_xml end end |