diff --git a/lib/inspec/resources/ssl.rb b/lib/inspec/resources/ssl.rb index 122b529fe..794b2a8af 100644 --- a/lib/inspec/resources/ssl.rb +++ b/lib/inspec/resources/ssl.rb @@ -73,6 +73,11 @@ module Inspec::Resources protocol: proto, ciphers: e.map(&:cipher), timeout: x.resource.timeout, retries: x.resource.retries, servername: x.resource.host)] end + + if !res[0].empty? && res[0][1].key?("error") && res[0][1]["error"].include?("Connection error Errno::ECONNREFUSED") + raise "#{res[0][1]["error"]}" + end + Hash[res] end .install_filter_methods_on_resource(self, :scan_config) diff --git a/test/unit/resources/ssl_test.rb b/test/unit/resources/ssl_test.rb index ed2445b7a..70830c21b 100644 --- a/test/unit/resources/ssl_test.rb +++ b/test/unit/resources/ssl_test.rb @@ -42,7 +42,8 @@ describe "Inspec::Resources::SSL" do it "verify host unreachable" do SSLShake.expects(:hello).at_least_once.returns({ "error" => "Connection error Errno::ECONNREFUSED, can't connect to localhost:443." }) resource = load_resource("ssl", host: "localhost") - _(resource.enabled?).must_equal false + err = _ { resource.enabled? }.must_raise(RuntimeError) + _(err.message).must_equal "Connection error Errno::ECONNREFUSED, can't connect to localhost:443." end it "error with nil host" do