Class: Ronin::DB::CertSubject

Inherits:
CertOrganization show all
Defined in:
lib/ronin/db/cert_subject.rb

Overview

Represents an subject of a SSL/TLS certificate.

Since:

  • 0.2.0

Constant Summary

Constants inherited from CertOrganization

Ronin::DB::CertOrganization::X509_ATTRIBUTES

Instance Attribute Summary collapse

Attributes inherited from CertOrganization

#country, #created_at, #id, #locality, #organization, #organizational_unit, #state

Class Method Summary collapse

Methods inherited from CertOrganization

parse

Methods included from Model

included

Instance Attribute Details

#certsArray<Cert>

The certificates that share this subject information.

Returns:



53
54
# File 'lib/ronin/db/cert_subject.rb', line 53

has_many :certs, foreign_key: :subject_id,
dependent:   :destroy

#common_nameCertName

The subject's common name (CN).

Returns:



36
37
# File 'lib/ronin/db/cert_subject.rb', line 36

belongs_to :common_name, class_name: 'CertName',
required:   true

Class Method Details

.import(name) ⇒ CertSubject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Imports the certificate subject's X509 distinguished name.

Parameters:

  • name (OpenSSL::X509::Name, String)

    The X509 name to parse and import.

Returns:

  • (CertSubject)

    The imported or pre-existing certificate subject.

Since:

  • 0.2.0



67
68
69
70
71
72
73
74
# File 'lib/ronin/db/cert_subject.rb', line 67

def self.import(name)
  attributes  = parse(name)
  common_name = attributes.fetch(:common_name)

  attributes[:common_name] = CertName.find_or_import(common_name)

  return find_or_create_by(attributes)
end