Class: Iostrust::Certificate
- Inherits:
-
Object
- Object
- Iostrust::Certificate
- Defined in:
- lib/iostrust/certificate.rb
Constant Summary collapse
- @@PLIST =
<<PLIST <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <array/> </plist> PLIST
Instance Method Summary collapse
- #cert_name ⇒ Object
- #data ⇒ Object
-
#initialize(cert_path) ⇒ Certificate
constructor
A new instance of Certificate.
- #sha1 ⇒ Object
- #subj ⇒ Object
- #tset ⇒ Object
Constructor Details
#initialize(cert_path) ⇒ Certificate
Returns a new instance of Certificate.
15 16 17 18 |
# File 'lib/iostrust/certificate.rb', line 15 def initialize(cert_path) raw_cert = File.read cert_path @cert = OpenSSL::X509::Certificate.new raw_cert end |
Instance Method Details
#cert_name ⇒ Object
20 21 22 |
# File 'lib/iostrust/certificate.rb', line 20 def cert_name @cert.subject.to_s end |
#data ⇒ Object
28 29 30 |
# File 'lib/iostrust/certificate.rb', line 28 def data @cert.to_der end |
#sha1 ⇒ Object
32 33 34 35 |
# File 'lib/iostrust/certificate.rb', line 32 def sha1 str = Digest::SHA1.hexdigest(data) [str].pack('H*') end |
#subj ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/iostrust/certificate.rb', line 37 def subj subj = "" asn_subject = OpenSSL::ASN1.decode(@cert.subject) asn_subject.each do |asn_sub| subj << asn_sub.to_der end subj end |
#tset ⇒ Object
24 25 26 |
# File 'lib/iostrust/certificate.rb', line 24 def tset return @@PLIST end |