Sha256: e9740fa5689238a55e4d135cd3d2875d45c606017a5ddba023de92582e932f7b

Contents?: true

Size: 1.06 KB

Versions: 5

Compression:

Stored size: 1.06 KB

Contents

module WWW
  class Mechanize
    class Chain
      class SSLResolver
        include WWW::Handler

        def initialize(ca_file, verify_callback, cert, key, pass)
          @ca_file = ca_file
          @verify_callback = verify_callback
          @cert = cert
          @key = key
          @pass = pass
        end

        def handle(ctx, params)
          uri       = params[:uri]
          http_obj  = params[:connection]
          if uri.scheme == 'https' && ! http_obj.started?
            http_obj.use_ssl = true
            http_obj.verify_mode = OpenSSL::SSL::VERIFY_NONE
            if @ca_file
              http_obj.ca_file = @ca_file
              http_obj.verify_mode = OpenSSL::SSL::VERIFY_PEER
              http_obj.verify_callback = @verify_callback if @verify_callback
            end
            if @cert && @key
              http_obj.cert = OpenSSL::X509::Certificate.new(::File.read(@cert))
              http_obj.key  = OpenSSL::PKey::RSA.new(::File.read(@key), @pass)
            end
          end
          super
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mechanize-0.8.0 lib/www/mechanize/chain/ssl_resolver.rb
mechanize-0.8.2 lib/www/mechanize/chain/ssl_resolver.rb
mechanize-0.8.4 lib/www/mechanize/chain/ssl_resolver.rb
mechanize-0.8.1 lib/www/mechanize/chain/ssl_resolver.rb
mechanize-0.8.3 lib/www/mechanize/chain/ssl_resolver.rb