class SAML2::KeyInfo

reference to an X.509 certificate, not solely a public key.
This represents the XML Signatures <KeyInfo> element, and actually contains a

def self.format_fingerprint(fingerprint)

Returns:
  • (String) -

Parameters:
  • fingerprint (String) --
def self.format_fingerprint(fingerprint)
  fingerprint.downcase.gsub(/(\h{2})(?=\h)/, '\1:')
end

def build(builder)

(see Base#build)
def build(builder)
  builder['dsig'].KeyInfo do |key_info|
    key_info['dsig'].X509Data do |x509_data|
      x509_data['dsig'].X509Certificate(x509)
    end
  end
end

def certificate

Returns:
  • (OpenSSL::X509::Certificate) -
def certificate
  @certificate ||= OpenSSL::X509::Certificate.new(Base64.decode64(x509))
end

def fingerprint

Returns:
  • (String) -
def fingerprint
  @fingerprint ||= self.class.format_fingerprint(Digest::SHA1.hexdigest(certificate.to_der))
end

def from_xml(node)

(see Base#from_xml)
def from_xml(node)
  self.x509 = node.at_xpath('dsig:KeyInfo/dsig:X509Data/dsig:X509Certificate', Namespaces::ALL)&.content&.strip
end

def initialize(x509 = nil)

Parameters:
  • x509 (String) -- The PEM encoded certificate.
def initialize(x509 = nil)
  self.x509 = x509
end

def x509=(value)

def x509=(value)
  @x509 = value&.gsub(/\w*-+(BEGIN|END) CERTIFICATE-+\w*/, "")&.strip
end