Class: ApnsKit::Certificate
- Inherits:
-
Object
- Object
- ApnsKit::Certificate
- Defined in:
- lib/apns_kit/certificate.rb
Instance Method Summary collapse
- #app_bundle_id ⇒ Object
- #development? ⇒ Boolean
-
#initialize(cert_data, passphrase = nil) ⇒ Certificate
constructor
A new instance of Certificate.
- #production? ⇒ Boolean
- #ssl_context ⇒ Object
- #universal? ⇒ Boolean
Constructor Details
#initialize(cert_data, passphrase = nil) ⇒ Certificate
Returns a new instance of Certificate.
4 5 6 7 |
# File 'lib/apns_kit/certificate.rb', line 4 def initialize(cert_data, passphrase = nil) @key = OpenSSL::PKey::RSA.new(cert_data, passphrase) @certificate = OpenSSL::X509::Certificate.new(cert_data) end |
Instance Method Details
#app_bundle_id ⇒ Object
28 29 30 |
# File 'lib/apns_kit/certificate.rb', line 28 def app_bundle_id @app_bundle_id ||= @certificate.subject.to_a.find { |key, *_| key == "UID" }[1] end |
#development? ⇒ Boolean
20 21 22 |
# File 'lib/apns_kit/certificate.rb', line 20 def development? extension(DEVELOPMENT_ENV_EXTENSION).present? end |
#production? ⇒ Boolean
16 17 18 |
# File 'lib/apns_kit/certificate.rb', line 16 def production? extension(PRODUCTION_ENV_EXTENSION).present? end |
#ssl_context ⇒ Object
9 10 11 12 13 14 |
# File 'lib/apns_kit/certificate.rb', line 9 def ssl_context @ssl_context ||= OpenSSL::SSL::SSLContext.new.tap do |context| context.key = @key context.cert = @certificate end end |
#universal? ⇒ Boolean
24 25 26 |
# File 'lib/apns_kit/certificate.rb', line 24 def universal? extension(UNIVERSAL_CERTIFICATE_EXTENSION).present? end |