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 +4 -4
- data/lib/apns_simple/client.rb +8 -8
- data/lib/apns_simple/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d385de91098bd7b8d3e0a1e16b805a1a363cedb
|
4
|
+
data.tar.gz: 4cfaadc0130767d6582a0cbcc22cce777f321b00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d0275e5f02eab67c8067c8413edde9b3e7b96e311204f556352315596f47f9d05528ae4ea84d98b302b537637186690d2813f1caad495bfe3004c972f24c03f
|
7
|
+
data.tar.gz: b81017fbeecd8e449957f9cf6aa84cbc81e8d93d77953308d0bc9202495db4f64f40e49207c9084148827a048649bb44a6560ecfe55f3582ecf2e448e3e6acdf
|
data/lib/apns_simple/client.rb
CHANGED
@@ -4,7 +4,7 @@ require 'socket'
|
|
4
4
|
module ApnsSimple
|
5
5
|
class Client
|
6
6
|
|
7
|
-
attr_reader :
|
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
|
-
|
26
|
-
|
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,
|
38
|
+
ssl = OpenSSL::SSL::SSLSocket.new(sock, ssl_context)
|
39
39
|
ssl.connect
|
40
40
|
ssl.write(notification.payload)
|
41
41
|
ssl.flush
|
data/lib/apns_simple/version.rb
CHANGED