Module: EmHttpSslPatch

### Home Classes Methods

### In Files

- lib/faraday/adapter/em_http_ssl_patch.rb

### Methods

- #certificate_store
- #host
- #ssl_handshake_completed
- #ssl_verify_peer
- #verify_peer?

### Class/Module Index

Quicksearch

- Faraday
- Faraday::Adapter
- Faraday::Adapter::EMHttp
- Faraday::Adapter::EMHttp::Manager
- Faraday::Adapter::EMHttp::Options
- Faraday::Adapter::EMSynchrony
- Faraday::Adapter::EMSynchrony::ParallelManager
- Faraday::Adapter::Excon
- Faraday::Adapter::HTTPClient
- Faraday::Adapter::NetHttp
- Faraday::Adapter::NetHttpPersistent
- Faraday::Adapter::Parallelism
- Faraday::Adapter::Patron
- Faraday::Adapter::Rack
- Faraday::Adapter::Test
- Faraday::Adapter::Test::Stub
- Faraday::Adapter::Test::Stubs
- Faraday::Adapter::Test::Stubs::NotFound
- Faraday::Adapter::Typhoeus
- Faraday::AutoloadHelper
- Faraday::ClientError
- Faraday::CompositeReadIO
- Faraday::Connection
- Faraday::ConnectionFailed
- Faraday::ConnectionOptions
- Faraday::Env
- Faraday::Error
- Faraday::FlatParamsEncoder
- Faraday::Middleware
- Faraday::MiddlewareRegistry
- Faraday::MissingDependency
- Faraday::NestedParamsEncoder
- Faraday::Options
- Faraday::ParsingError
- Faraday::ProxyOptions
- Faraday::RackBuilder
- Faraday::RackBuilder::Handler
- Faraday::RackBuilder::StackLocked
- Faraday::Request
- Faraday::Request::Authorization
- Faraday::Request::BasicAuthentication
- Faraday::Request::Instrumentation
- Faraday::Request::Instrumentation::Options
- Faraday::Request::Multipart
- Faraday::Request::Retry
- Faraday::Request::Retry::Options
- Faraday::Request::TokenAuthentication
- Faraday::Request::UrlEncoded
- Faraday::RequestOptions
- Faraday::ResourceNotFound
- Faraday::Response
- Faraday::Response::Logger
- Faraday::Response::Middleware
- Faraday::Response::RaiseError
- Faraday::SSLError
- Faraday::SSLOptions
- Faraday::TimeoutError
- Faraday::Utils
- Faraday::Utils::Headers
- Faraday::Utils::ParamsHash
- EmHttpSslPatch
- Object

No matching classes.

# EmHttpSslPatch

### Public Instance Methods

certificate_store() click to toggle source

    # File lib/faraday/adapter/em_http_ssl_patch.rb, line 45
    def certificate_store
      @certificate_store ||= begin
        store = OpenSSL::X509::Store.new
        store.set_default_paths
        ca_file = parent.connopts.tls[:cert_chain_file]
        store.add_file(ca_file) if ca_file
        store
      end
    end

host() click to toggle source

    # File lib/faraday/adapter/em_http_ssl_patch.rb, line 41
    def host
      parent.connopts.host
    end

ssl_handshake_completed() click to toggle source

    # File lib/faraday/adapter/em_http_ssl_patch.rb, line 27
    def ssl_handshake_completed
      return true unless verify_peer?

      unless OpenSSL::SSL.verify_certificate_identity(@last_seen_cert, host)
        raise OpenSSL::SSL::SSLError.new(%(host "#{host}" does not match the server certificate))
      else
        true
      end
    end

ssl_verify_peer(cert_string) click to toggle source

    # File lib/faraday/adapter/em_http_ssl_patch.rb, line 5
    def ssl_verify_peer(cert_string)
      cert = nil
      begin
        cert = OpenSSL::X509::Certificate.new(cert_string)
      rescue OpenSSL::X509::CertificateError
        return false
      end

      @last_seen_cert = cert

      if certificate_store.verify(@last_seen_cert)
        begin
          certificate_store.add_cert(@last_seen_cert)
        rescue OpenSSL::X509::StoreError => e
          raise e unless e.message == 'cert already in hash table'
        end
        true
      else
        raise OpenSSL::SSL::SSLError.new(%(unable to verify the server certificate for "#{host}"))
      end
    end

verify_peer?() click to toggle source

    # File lib/faraday/adapter/em_http_ssl_patch.rb, line 37
    def verify_peer?
      parent.connopts.tls[:verify_peer]
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.