Module: Pushofy::ConnectionToAppleServer

Defined in:
lib/pushofy/ssl_helper.rb

Class Method Summary collapse

Class Method Details

.ssl_connect(host, port, password, cerfile) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/pushofy/ssl_helper.rb', line 7

def self.ssl_connect(host, port, password,cerfile)
  ssl_connect = SSLConnection.new
  ssl_connect.context = OpenSSL::SSL::SSLContext.new
  key4_pem = File.read(cerfile)
  ssl_connect.context.key = OpenSSL::PKey::RSA.new(key4_pem, password)
  ssl_connect.context.cert = OpenSSL::X509::Certificate.new(key4_pem)
  ssl_connect.tcp_client = TCPSocket.new host, port
  OpenSSL::SSL::SSLSocket.new(ssl_connect.tcp_client, ssl_connect.context)
end