mirror of
https://github.com/inspec/inspec
synced 2024-11-26 22:50:36 +00:00
feature: add ssl support for winrm
This commit is contained in:
parent
f165e51e1f
commit
5714395232
1 changed files with 19 additions and 4 deletions
|
@ -59,14 +59,29 @@ elsif ENV['WINRM_SPEC']
|
|||
set :backend, :winrm
|
||||
set :os, :family => 'windows'
|
||||
|
||||
ssl = false
|
||||
user = ENV['LOGIN_USERNAME']
|
||||
pass = ENV['LOGIN_PASSWORD']
|
||||
host = ENV['TARGET_HOST']
|
||||
port = ENV['TARGET_PORT'] || '5985'
|
||||
endpoint = "http://#{host}:#{port}/wsman"
|
||||
port = ENV['LOGIN_PORT'] || '5985'
|
||||
|
||||
winrm = ::WinRM::WinRMWebService.new(endpoint, :ssl, :user => user, :pass => pass, :basic_auth_only => true)
|
||||
# check if we should use ssl
|
||||
ssl = ENV['WINRM_SSL']
|
||||
if (ssl)
|
||||
scheme = "https"
|
||||
else
|
||||
scheme = "http"
|
||||
end
|
||||
|
||||
# deactivate certificate check if requested, default is on
|
||||
accept_self_signed = false
|
||||
if (ENV['WINRM_SELF_SIGNED_CERT'])
|
||||
accept_self_signed = true
|
||||
end
|
||||
|
||||
endpoint = "#{scheme}://#{host}:#{port}/wsman"
|
||||
puts "Use endpoint #{endpoint}"
|
||||
|
||||
winrm = ::WinRM::WinRMWebService.new(endpoint, :ssl, :user => user, :pass => pass, :basic_auth_only => true, :no_ssl_peer_verification => accept_self_signed)
|
||||
winrm.set_timeout 300 # 5 minutes max timeout for any operation
|
||||
Specinfra.configuration.winrm = winrm
|
||||
|
||||
|
|
Loading…
Reference in a new issue