Class: Keychain::Certificate

Inherits:
Sec::Base
  • Object
show all
Defined in:
lib/keychain/certificate.rb

Constant Summary collapse

ATTR_MAP =
{CF::Base.typecast(Sec::kSecAttrAccessGroup) => :access_group,
CF::Base.typecast(Sec::kSecAttrCertificateType) => :certificate_type,
CF::Base.typecast(Sec::kSecAttrCertificateEncoding) => :certificate_encoding,
CF::Base.typecast(Sec::kSecAttrLabel) => :label,
CF::Base.typecast(Sec::kSecAttrSubject) => :subject,
CF::Base.typecast(Sec::kSecAttrIssuer) => :issuer,
CF::Base.typecast(Sec::kSecAttrSerialNumber) => :serial_number,
CF::Base.typecast(Sec::kSecAttrSubjectKeyID) => :subject_key_id,
CF::Base.typecast(Sec::kSecAttrPublicKeyHash) => :public_key_hash}
INVERSE_ATTR_MAP =
ATTR_MAP.invert

Instance Attribute Summary

Attributes inherited from Sec::Base

#attributes

Instance Method Summary collapse

Methods inherited from Sec::Base

define_attributes, #initialize, #keychain, #load_attributes, register_type, #update_self_from_dictionary

Constructor Details

This class inherits a constructor from Sec::Base

Instance Method Details

#klassObject



38
39
40
# File 'lib/keychain/certificate.rb', line 38

def klass
  Sec::Classes::CERTIFICATE.to_ruby
end

#public_keyObject



42
43
44
45
46
47
48
# File 'lib/keychain/certificate.rb', line 42

def public_key
  key_ref = FFI::MemoryPointer.new(:pointer)
  status = Sec.SecCertificateCopyPublicKey(self, key_ref)
  Sec.check_osstatus(status)

  Key.new(key_ref.read_pointer).release_on_gc
end

#x509Object



50
51
52
53
54
55
56
57
# File 'lib/keychain/certificate.rb', line 50

def x509
  data_ptr = Sec.SecCertificateCopyData(self)
  data = CF::Data.new(data_ptr)

  result = OpenSSL::X509::Certificate.new(data.to_s)
  data.release
  result
end