Class: ApnsKit::Certificate

Inherits:
Object
  • Object
show all
Defined in:
lib/apns_kit/certificate.rb

Instance Method Summary collapse

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_idObject



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

Returns:

  • (Boolean)


20
21
22
# File 'lib/apns_kit/certificate.rb', line 20

def development?
    extension(DEVELOPMENT_ENV_EXTENSION).present?
end

#production?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/apns_kit/certificate.rb', line 16

def production?
    extension(PRODUCTION_ENV_EXTENSION).present?
end

#ssl_contextObject



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

Returns:

  • (Boolean)


24
25
26
# File 'lib/apns_kit/certificate.rb', line 24

def universal?
    extension(UNIVERSAL_CERTIFICATE_EXTENSION).present?
end