Sha256: 3da9564c3f825bbc697855fdae64abf63cbe8089fc2ab5e1d4a52f643c9799af

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

module Wazuh
  module Sawyer
    module Connection
      private

      def connection
        options = {
          headers: {
            'Accept' => 'application/json; charset=utf-8',
            'Content-Type' => 'application/json'
          },
          ssl: {}
        }

        options[:headers]['User-Agent'] = user_agent if user_agent
        options[:ssl].merge!({ client_cert: client_cert, client_key: client_key }) if client_cert || client_key
        options[:ssl][:ca_file] = ca_file if ca_file

        if basic_user || basic_password
          authorization_header = "Basic " + Base64.encode64(basic_user + ':' + basic_password).strip
          options[:headers].merge!({'Authorization' => authorization_header})
        end

        options[:ssl].merge!({ verify: false }) unless verify_ssl

        opts = {
          :links_parser => ::Sawyer::LinkParsers::Simple.new
        }

        opts[:faraday] = ::Faraday.new(options)
        opts[:faraday].proxy = nil if ignore_env_proxy

        ::Sawyer::Agent.new(endpoint, opts)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wazuh-ruby-client-0.2.9 lib/wazuh/sawyer/connection.rb