apns_simple 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fb195eb140e6855b25d09edcccd88286657471ee
4
- data.tar.gz: 505a896558089c3669069f113d63ae7980f54722
3
+ metadata.gz: 7d385de91098bd7b8d3e0a1e16b805a1a363cedb
4
+ data.tar.gz: 4cfaadc0130767d6582a0cbcc22cce777f321b00
5
5
  SHA512:
6
- metadata.gz: 4890e92148e9ebdd47f24bb72f4863668026c58e0b7172d24584d22a75704a621641220cd98fdb4fabef539944e733d440437e79b367b3ba8cbfff23b59955f8
7
- data.tar.gz: 6c330fa2365275cf48de0a7e720a30a7eef5646badeddab9c19a83eaba5af28a8d91b45e71e918a292638b27c6291d4d39c0b32df0678fba54f7fb4bb07b68aa
6
+ metadata.gz: 8d0275e5f02eab67c8067c8413edde9b3e7b96e311204f556352315596f47f9d05528ae4ea84d98b302b537637186690d2813f1caad495bfe3004c972f24c03f
7
+ data.tar.gz: b81017fbeecd8e449957f9cf6aa84cbc81e8d93d77953308d0bc9202495db4f64f40e49207c9084148827a048649bb44a6560ecfe55f3582ecf2e448e3e6acdf
@@ -4,7 +4,7 @@ require 'socket'
4
4
  module ApnsSimple
5
5
  class Client
6
6
 
7
- attr_reader :certificate, :passphrase, :host, :port
7
+ attr_reader :ssl_context, :host, :port
8
8
 
9
9
  COMMAND = 8
10
10
  CODES = {
@@ -22,20 +22,20 @@ module ApnsSimple
22
22
  }
23
23
 
24
24
  def initialize(options)
25
- @certificate = options.fetch(:certificate)
26
- @passphrase = options[:passphrase] || ''
25
+ certificate = options.fetch(:certificate)
26
+ passphrase = options[:passphrase] || ''
27
+ @ssl_context = OpenSSL::SSL::SSLContext.new(:TLSv1)
28
+ @ssl_context.key = OpenSSL::PKey::RSA.new(certificate, passphrase)
29
+ @ssl_context.cert = OpenSSL::X509::Certificate.new(certificate)
30
+
27
31
  gateway_uri = options[:gateway_uri] || 'apn://gateway.push.apple.com:2195'
28
32
  @host, @port = parse_gateway_uri(gateway_uri)
29
33
  end
30
34
 
31
35
  def push(notification)
32
36
  begin
33
- ctx = OpenSSL::SSL::SSLContext.new(:TLSv1)
34
- ctx.key = OpenSSL::PKey::RSA.new(certificate, passphrase)
35
- ctx.cert = OpenSSL::X509::Certificate.new(certificate)
36
-
37
37
  sock = TCPSocket.new(host, port)
38
- ssl = OpenSSL::SSL::SSLSocket.new(sock, ctx)
38
+ ssl = OpenSSL::SSL::SSLSocket.new(sock, ssl_context)
39
39
  ssl.connect
40
40
  ssl.write(notification.payload)
41
41
  ssl.flush
@@ -1,3 +1,3 @@
1
1
  module ApnsSimple
2
- VERSION = '0.5.0'
2
+ VERSION = '0.5.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apns_simple
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey Voronkov