lib/soap/winrm_service.rb in winrm-0.0.3 vs lib/soap/winrm_service.rb in winrm-0.0.4
- old
+ new
@@ -37,10 +37,14 @@
def self.set_auth(user,pass)
@@user = user
@@pass = pass
end
+ def self.set_ca_trust_path(file_or_dir)
+ @@ca_trust_store = file_or_dir
+ end
+
# Turn off parsing and just return the soap response
def self.raw_soap!
@@raw_soap = true
end
@@ -95,10 +99,11 @@
end
def on_after_create_http_request(req)
req.set_auth @@user, @@pass
req.set_header('Content-Type','application/soap+xml;charset=UTF-8')
+ req.set_trust_ca_file(@@ca_trust_store) if defined?(@@ca_trust_store)
#puts "SOAP DOCUMENT=\n#{req.body}"
end
def on_http_error(resp)
puts "HTTP ERROR: #{resp.status}"
@@ -235,11 +240,14 @@
def run_powershell_script(script_file)
script = File.read(script_file)
script = script.chars.to_a.join("\x00").chomp
if(defined?(script.encode))
script = script.encode('ASCII-8BIT')
+ script = Base64.strict_encode64(script)
+ else
+ script = Base64.encode64(script).chomp
end
- script = Base64.encode64(script)
+
shell_id = open_shell
command_id = run_command(shell_id, "powershell -encodedCommand #{script}")
command_output = get_command_output(shell_id, command_id)
cleanup_command(shell_id, command_id)