class SSLyze::XML::Certinfo::Certificate

Represents the `<certificate>` XML element.

Public Class Methods

new(node) click to toggle source

Initializes the certificate.

@param [Nokogiri::XML::Node] node

The `<certificate>` XML element.
# File lib/sslyze/xml/certinfo/certificate.rb, line 22
def initialize(node)
  @node = node
end

Public Instance Methods

==(other) click to toggle source

Compares the other certificiate to this certificate.

@param [Certificate] other

The other certificate.

@return [Boolean]

Whether the other certificate has the same {#as_pem}.

@since 1.0.0

# File lib/sslyze/xml/certinfo/certificate.rb, line 195
def ==(other)
  other.kind_of?(self.class) && other.as_pem == as_pem
end
as_pem() click to toggle source

The AS PEM information.

@return [String]

# File lib/sslyze/xml/certinfo/certificate.rb, line 31
def as_pem
  @as_pem ||= @node.at_xpath('asPEM').inner_text
end
Also aliased as: to_s
extensions() click to toggle source

@return [X509::ExtensionSet]

@group OpenSSL Methods

# File lib/sslyze/xml/certinfo/certificate.rb, line 55
def extensions
  X509::ExtensionSet.new(x509.extensions)
end
hpkp_sha256_pin() click to toggle source

The HPKP SHA256 Pin.

@return [String]

@since 1.0.0

# File lib/sslyze/xml/certinfo/certificate.rb, line 169
def hpkp_sha256_pin
  @hpkp_sha256_pin ||= @node['hpkpSha256Pin']
end
issuer() click to toggle source

@return [X509::Name]

@see www.rubydoc.info/stdlib/openssl/OpenSSL/X509/Name

@group OpenSSL Methods

# File lib/sslyze/xml/certinfo/certificate.rb, line 66
def issuer
  @issuer ||= X509::Name.new(x509.issuer)
end
not_after() click to toggle source

@return [Time]

@group OpenSSL Methods

# File lib/sslyze/xml/certinfo/certificate.rb, line 75
def not_after
  x509.not_after
end
not_before() click to toggle source

@return [Time]

@group OpenSSL Methods

# File lib/sslyze/xml/certinfo/certificate.rb, line 84
def not_before
  x509.not_before
end
public_key() click to toggle source

@return [PublicKey]

@group OpenSSL Methods

# File lib/sslyze/xml/certinfo/certificate.rb, line 93
def public_key
  @public_key ||= PublicKey.new(@node.at_xpath('publicKey'))
end
serial() click to toggle source

@return [OpenSSL::BN]

@see www.rubydoc.info/stdlib/openssl/OpenSSL/BN

@group OpenSSL Methods

# File lib/sslyze/xml/certinfo/certificate.rb, line 104
def serial
  x509.serial
end
sha1_fingerprint() click to toggle source

The SHA1 fingerprint of the cert.

@return [String]

# File lib/sslyze/xml/certinfo/certificate.rb, line 158
def sha1_fingerprint
  @sha1_fingerprint ||= @node['sha1Fingerprint']
end
signature_algorithm() click to toggle source

@return [String]

@group OpenSSL Methods

# File lib/sslyze/xml/certinfo/certificate.rb, line 113
def signature_algorithm
  x509.signature_algorithm
end
subject() click to toggle source

@return [X509::Name]

@group OpenSSL Methods

# File lib/sslyze/xml/certinfo/certificate.rb, line 122
def subject
  @subject ||= X509::Name.new(x509.subject)
end
supplied_server_name_indication() click to toggle source

The supplied server name indication.

@return [String]

@since 1.0.0

# File lib/sslyze/xml/certinfo/certificate.rb, line 180
def supplied_server_name_indication
  @supplied_server_name_indication ||= @node['suppliedServerNameIndication']
end
to_der() click to toggle source

@return [String]

@group OpenSSL Methods

# File lib/sslyze/xml/certinfo/certificate.rb, line 131
def to_der
  x509.to_der
end
to_s()
Alias for: as_pem
to_text() click to toggle source

@return [String]

@group OpenSSL Methods

# File lib/sslyze/xml/certinfo/certificate.rb, line 140
def to_text
  x509.to_text
end
version() click to toggle source

@return [Integer]

@group OpenSSL Methods

# File lib/sslyze/xml/certinfo/certificate.rb, line 149
def version
  x509.version
end
x509() click to toggle source

The parsed X509 certificate.

@return [OpenSSL::X509::Certificate]

@see www.rubydoc.info/stdlib/openssl/OpenSSL/X509/Certificate

@since 1.0.0

# File lib/sslyze/xml/certinfo/certificate.rb, line 46
def x509
  @x509 ||= OpenSSL::X509::Certificate.new(as_pem)
end