Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: 619f1b86c2
Fetching contributors…

Cannot retrieve contributors at this time

37 lines (27 sloc) 0.916 kB
class ApnsClient
attr_accessor :certificate, :key, :host, :port
def initialize(certificate, key, host = 'gateway.push.apple.com', port = 2195)
@certificate, @key, @host, @port = certificate, path, host, port
end
def connect!
raise "The path to your pem file is not set." unless self.pem
raise "The path to your pem file does not exist!" unless File.exist?(self.pem)
@context = OpenSSL::SSL::SSLContext.new
@context.cert = OpenSSL::X509::Certificate.new(File.read(self.pem))
@context.key = OpenSSL::PKey::RSA.new(File.read(self.pem), self.pass)
@sock = TCPSocket.new(self.host, self.port)
@ssl = OpenSSL::SSL::SSLSocket.new(@sock, @context)
@ssl.connect
return @sock, @ssl
end
def disconnect!
@ssl.close
@sock.close
end
def write(bytes)
@ssl.write(bytes)
end
def connected?
@ssl
end
end
Jump to Line
Something went wrong with that request. Please try again.