Sha256: e982a8a208e09b59351eda7173dc17c0f0655915bfb51cd4c3feb66fb7b3ceaa

Contents?: true

Size: 1.81 KB

Versions: 8

Compression:

Stored size: 1.81 KB

Contents

# Allows a `Puppet::SSL::Validator` to be used in situations where a
# `Verifier` is required, while preserving the legacy validator behavior of:
#
# * Loading CA certs from `ssl_client_ca_auth` or `localcacert`
# * Verifying each cert in the peer's chain is contained in the file
#   loaded above.
#
class Puppet::SSL::VerifierAdapter
  attr_reader :validator

  def initialize(validator)
    @validator = validator
  end

  # Return true if `self` is reusable with `verifier` meaning they
  # are both using the same class of `Puppet::SSL::Validator`. In this
  # case we only care the Validator class is the same. We can't require
  # the same instances, because a new instance is created each time
  # HttpPool.http_instance is called.
  #
  # @param verifier [Puppet::SSL::Verifier] the verifier to compare against
  # @return [Boolean] return true if a cached connection can be used, false otherwise
  def reusable?(verifier)
    verifier.instance_of?(self.class) &&
      verifier.validator.instance_of?(@validator.class)
  end

  # Configure the `http` connection based on the current `ssl_context`.
  #
  # @param http [Net::HTTP] connection
  # @api private
  def setup_connection(http)
    @validator.setup_connection(http)
  end

  # Handle an SSL connection error.
  #
  # @param http [Net::HTTP] connection
  # @param error [OpenSSL::SSL::SSLError] connection error
  # @return (see Puppet::SSL::Verifier#handle_connection_error)
  # @raise [Puppet::SSL::CertVerifyError] SSL connection failed due to a
  #   verification error with the server's certificate or chain
  # @raise [Puppet::Error] server hostname does not match certificate
  # @raise [OpenSSL::SSL::SSLError] low-level SSL connection failure
  def handle_connection_error(http, error)
    Puppet::Util::SSL.handle_connection_error(error, @validator, http.address)
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
puppet-6.4.1 lib/puppet/ssl/verifier_adapter.rb
puppet-6.4.1-x86-mingw32 lib/puppet/ssl/verifier_adapter.rb
puppet-6.4.1-x64-mingw32 lib/puppet/ssl/verifier_adapter.rb
puppet-6.4.1-universal-darwin lib/puppet/ssl/verifier_adapter.rb
puppet-6.4.0 lib/puppet/ssl/verifier_adapter.rb
puppet-6.4.0-x86-mingw32 lib/puppet/ssl/verifier_adapter.rb
puppet-6.4.0-x64-mingw32 lib/puppet/ssl/verifier_adapter.rb
puppet-6.4.0-universal-darwin lib/puppet/ssl/verifier_adapter.rb