Class: Rex::Proto::CryptoAsn1::Cms::Certificate

Inherits:
Object
  • Object
show all
Defined in:
lib/rex/proto/crypto_asn1/cms.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Certificate

Returns a new instance of Certificate.



15
16
17
# File 'lib/rex/proto/crypto_asn1/cms.rb', line 15

def initialize(options={})
  self.options = options
end

Instance Attribute Details

#optionsObject

Rather than specifying the entire structure of a certificate, we pass this off to OpenSSL, effectively providing an interface between RASN and OpenSSL.



13
14
15
# File 'lib/rex/proto/crypto_asn1/cms.rb', line 13

def options
  @options
end

Instance Method Details

#can_build?Boolean

RASN1 Glue method - Say if DER can be built (not default value, not optional without value, has a value)

Returns:

  • (Boolean)

Since:

  • 0.12



26
27
28
# File 'lib/rex/proto/crypto_asn1/cms.rb', line 26

def can_build?
  !to_der.empty?
end

#parse!(str, ber: false) ⇒ Object



40
41
42
43
# File 'lib/rex/proto/crypto_asn1/cms.rb', line 40

def parse!(str, ber: false)
  self.options[:openssl_certificate] = OpenSSL::X509::Certificate.new(str)
  to_der.length
end

#primitive?Boolean

RASN1 Glue method

Returns:

  • (Boolean)


31
32
33
# File 'lib/rex/proto/crypto_asn1/cms.rb', line 31

def primitive?
  false
end

#to_derObject



19
20
21
# File 'lib/rex/proto/crypto_asn1/cms.rb', line 19

def to_der
  self.options[:openssl_certificate]&.to_der || ''
end

#valueObject

RASN1 Glue method



36
37
38
# File 'lib/rex/proto/crypto_asn1/cms.rb', line 36

def value
  options[:openssl_certificate]
end