module SSLyze::XML::Certinfo::HasCertificates

@since 1.0.0

Public Instance Methods

certificates() click to toggle source

Returns all certificates in the chain.

@return [Array<Certificate>]

# File lib/sslyze/xml/certinfo/has_certificates.rb, line 42
def certificates
  each_certificate.to_a
end
Also aliased as: certs
certs()
Alias for: certificates
each()
Alias for: each_certificate
each_cert()
Alias for: each_certificate
each_certificate() { |certificate| ... } click to toggle source

Enumerates over each certificate in the chain.

@yield [cert]

The given block will be passed each certificate.

@yieldparam [Certificate] cert

A certificate in the chain.

@return [Enumerator]

If no block was given, an Enumerator will be returned.
# File lib/sslyze/xml/certinfo/has_certificates.rb, line 26
def each_certificate
  return enum_for(__method__) unless block_given?

  @node.xpath('certificate').each do |element|
    yield Certificate.new(element)
  end
end
Also aliased as: each_cert, each
each_intermediate() { |certificate| ... } click to toggle source

Enumerates over any intermediate certificates in the chain.

@yield [cert]

The given block will be passed each intermediate certificate.

@yieldparam [Certificate] cert

An intermediate certificate in the chain.

@return [Enumerator]

If no block was given, an Enumerator will be returned.
# File lib/sslyze/xml/certinfo/has_certificates.rb, line 71
def each_intermediate
  return enum_for(__method__) unless block_given?

  @node.xpath('certificate[position() > 1 and position() < last()]').each do |element|
    yield Certificate.new(element)
  end
end
intermediates() click to toggle source

Returns all intermediate certificates in the chain.

@return [Array<Certificate>]

# File lib/sslyze/xml/certinfo/has_certificates.rb, line 84
def intermediates
  each_intermediate.to_a
end
leaf() click to toggle source

The leaf certificate.

@return [Certificate, nil]

# File lib/sslyze/xml/certinfo/has_certificates.rb, line 53
def leaf
  if (element = @node.at_xpath('certificate[1]'))
    Certificate.new(element)
  end
end
root() click to toggle source

The root certificate.

@return [Certificate, nil]

# File lib/sslyze/xml/certinfo/has_certificates.rb, line 93
def root
  if (element = @node.at_xpath('certificate[last()]'))
    Certificate.new(element)
  end
end