Module: Gem::PqTlsPolicy::Patch

Defined in:
lib/rubygems_pq_tls_policy/patch.rb

Instance Method Summary collapse

Instance Method Details

#post_connection_check(hostname) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/rubygems_pq_tls_policy/patch.rb', line 6

def post_connection_check(hostname)
  result = super

  config = Gem::PqTlsPolicy.config
  return result unless config.enabled?

  config.validate!

  group = respond_to?(:group) ? self.group : nil

  if config.trace?
    warn "[rubygems:tls] host=#{hostname} version=#{safe_ssl_version} cipher=#{safe_cipher_name} group=#{group.inspect}"
  end

  if config.pq_required? && !config.allowed_groups.include?(group)
    raise Gem::PqTlsPolicy::Violation,
      "RubyGems gem-server TLS key exchange policy violation: " \
      "host=#{hostname.inspect} used group=#{group.inspect}; " \
      "allowed=#{config.allowed_groups.join(',')}"
  end

  result
end