Exception: Puppet::SSL::CertMismatchError

Inherits:
SSLError show all
Defined in:
lib/puppet/ssl/error.rb

Instance Attribute Summary

Attributes inherited from Error

#original

Instance Method Summary collapse

Constructor Details

#initialize(peer_cert, host) ⇒ CertMismatchError

Returns a new instance of CertMismatchError.



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/puppet/ssl/error.rb', line 17

def initialize(peer_cert, host)
  valid_certnames = [peer_cert.subject.to_utf8.sub(/.*=/, ''),
                     *Puppet::SSL::Certificate.subject_alt_names_for(peer_cert)].uniq
  if valid_certnames.size > 1
    expected_certnames = _("expected one of %{certnames}") % { certnames: valid_certnames.join(', ') }
  else
    expected_certnames = _("expected %{certname}") % { certname: valid_certnames.first }
  end

  super(_("Server hostname '%{host}' did not match server certificate; %{expected_certnames}") % { host: host, expected_certnames: expected_certnames })
end