def self.load_secret(path=nil)
path = path || Chef::Config[:encrypted_data_bag_secret] || DEFAULT_SECRET_FILE
secret = case path
when /^\w+:\/\//
begin
Kernel.open(path).read.strip
rescue Errno::ECONNREFUSED
raise ArgumentError, "Remote key not available from '#{path}'"
rescue OpenURI::HTTPError
raise ArgumentError, "Remote key not found at '#{path}'"
end
else
if !File.exists?(path)
raise Errno::ENOENT, "file not found '#{path}'"
end
IO.read(path).strip
end
if secret.size < 1
raise ArgumentError, "invalid zero length secret in '#{path}'"
end
secret
end