Class: Metasploit::Credential::Pkcs12

Inherits:
Private
  • Object
show all
Defined in:
app/models/metasploit/credential/pkcs12.rb

Overview

A private Pkcs12 file.

Instance Attribute Summary collapse

Attributes inherited from Private

#cores, #created_at, #id, #type, #updated_at

Instance Method Summary collapse

Instance Attribute Details

#dataString

A private pkcs12 file, base64 encoded - i.e. starting with ‘MIIMhgIBAzCCDFAGCSqGSIb3DQEHAaCC.…’

Returns:

  • (String)


# File 'app/models/metasploit/credential/pkcs12.rb', line 10

Instance Method Details

#openssl_pkcs12OpenSSL::PKCS12

Converts the private pkcs12 data in #data to an ‘OpenSSL::PKCS12` instance.

Returns:

  • (OpenSSL::PKCS12)

Raises:

  • (ArgumentError)

    if #data cannot be loaded



41
42
43
44
45
46
47
48
49
50
# File 'app/models/metasploit/credential/pkcs12.rb', line 41

def openssl_pkcs12
  if data
    begin
      password = ''
      OpenSSL::PKCS12.new(Base64.strict_decode64(data), password)
    rescue OpenSSL::PKCS12::PKCS12Error => error
      raise ArgumentError.new(error)
    end
  end
end

#to_sString

The key data‘s fingerprint, suitable for displaying to the user.

Returns:

  • (String)


56
57
58
59
60
61
62
63
64
# File 'app/models/metasploit/credential/pkcs12.rb', line 56

def to_s
  return '' unless data

  cert = openssl_pkcs12.certificate
  result = []
  result << "subject:#{cert.subject.to_s}"
  result << "issuer:#{cert.issuer.to_s}"
  result.join(',')
end