apns_simple 0.5.1 → 0.7.0
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 +9 -4
- data/lib/apns_simple/version.rb +1 -1
- data/lib/apns_simple.rb +1 -0
- 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: 13495bdc2326149e669f53bf4e903bc60dc21884
|
4
|
+
data.tar.gz: 6b843d787e0db08bf2f7926ec5861d6367ffbdbb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89e66bc31760f4f109408eb2e838042ced0395483ac3293e8abe466eaa8940bca14b11693b43ac48db35811537291123f4631cdfb01d778850800954a621f675
|
7
|
+
data.tar.gz: 88d9af28a6059906f4afa40ff4d8794990e62ba008127b53e8a8019ee7eb76d501c6bd5783385ad1cbd7286f006bf7e0bd4e8b60f131bc498a1c80dca0b621ae
|
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 :ssl_context, :host, :port
|
7
|
+
attr_reader :certificate, :ssl_context, :host, :port
|
8
8
|
|
9
9
|
COMMAND = 8
|
10
10
|
CODES = {
|
@@ -22,11 +22,10 @@ module ApnsSimple
|
|
22
22
|
}
|
23
23
|
|
24
24
|
def initialize(options)
|
25
|
-
certificate = options.fetch(:certificate)
|
25
|
+
@certificate = options.fetch(:certificate)
|
26
26
|
passphrase = options[:passphrase] || ''
|
27
|
-
@ssl_context = OpenSSL::SSL::SSLContext.new
|
27
|
+
@ssl_context = OpenSSL::SSL::SSLContext.new
|
28
28
|
@ssl_context.key = OpenSSL::PKey::RSA.new(certificate, passphrase)
|
29
|
-
@ssl_context.cert = OpenSSL::X509::Certificate.new(certificate)
|
30
29
|
|
31
30
|
gateway_uri = options[:gateway_uri] || 'apn://gateway.push.apple.com:2195'
|
32
31
|
@host, @port = parse_gateway_uri(gateway_uri)
|
@@ -34,6 +33,12 @@ module ApnsSimple
|
|
34
33
|
|
35
34
|
def push(notification)
|
36
35
|
begin
|
36
|
+
current_time = Time.now.utc
|
37
|
+
cert = OpenSSL::X509::Certificate.new(certificate)
|
38
|
+
if current_time < cert.not_before || current_time > cert.not_after
|
39
|
+
raise CertificateActivenessTimeError, "CURRENT_TIME: #{current_time}, NOT_BEFORE: #{cert.not_before}, NOT_AFTER: #{cert.not_after}"
|
40
|
+
end
|
41
|
+
ssl_context.cert = cert
|
37
42
|
sock = TCPSocket.new(host, port)
|
38
43
|
ssl = OpenSSL::SSL::SSLSocket.new(sock, ssl_context)
|
39
44
|
ssl.connect
|
data/lib/apns_simple/version.rb
CHANGED
data/lib/apns_simple.rb
CHANGED