class ApnsKit::Certificate

Public Class Methods

from_p12_file(data, passphrase = nil) click to toggle source
# File lib/apns_kit/certificate.rb, line 6
def from_p12_file(data, passphrase = nil)
    p12 = OpenSSL::PKCS12.new(data, passphrase)
    ApnsKit::Certificate.new(p12.key, p12.certificate)
end
from_pem_file(data, passphrase = nil) click to toggle source
# File lib/apns_kit/certificate.rb, line 11
def from_pem_file(data, passphrase = nil)
    key = OpenSSL::PKey::RSA.new(data, passphrase)
    certificate = OpenSSL::X509::Certificate.new(data)
    ApnsKit::Certificate.new(key, certificate)
end
new(key, certificate) click to toggle source
# File lib/apns_kit/certificate.rb, line 19
def initialize(key, certificate)
    @key = key
    @certificate = certificate
end

Public Instance Methods

app_bundle_id() click to toggle source
# File lib/apns_kit/certificate.rb, line 43
def app_bundle_id
    @app_bundle_id ||= @certificate.subject.to_a.find { |key, *_| key == "UID" }[1]
end
development?() click to toggle source
# File lib/apns_kit/certificate.rb, line 35
def development?
    extension(DEVELOPMENT_ENV_EXTENSION).present?
end
production?() click to toggle source
# File lib/apns_kit/certificate.rb, line 31
def production?
    extension(PRODUCTION_ENV_EXTENSION).present?
end
ssl_context() click to toggle source
# File lib/apns_kit/certificate.rb, line 24
def ssl_context
    @ssl_context ||= OpenSSL::SSL::SSLContext.new.tap do |context|
        context.key = @key
        context.cert = @certificate
    end
end
universal?() click to toggle source
# File lib/apns_kit/certificate.rb, line 39
def universal?
    extension(UNIVERSAL_CERTIFICATE_EXTENSION).present?
end