apns_simple 0.5.1 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7d385de91098bd7b8d3e0a1e16b805a1a363cedb
4
- data.tar.gz: 4cfaadc0130767d6582a0cbcc22cce777f321b00
3
+ metadata.gz: 13495bdc2326149e669f53bf4e903bc60dc21884
4
+ data.tar.gz: 6b843d787e0db08bf2f7926ec5861d6367ffbdbb
5
5
  SHA512:
6
- metadata.gz: 8d0275e5f02eab67c8067c8413edde9b3e7b96e311204f556352315596f47f9d05528ae4ea84d98b302b537637186690d2813f1caad495bfe3004c972f24c03f
7
- data.tar.gz: b81017fbeecd8e449957f9cf6aa84cbc81e8d93d77953308d0bc9202495db4f64f40e49207c9084148827a048649bb44a6560ecfe55f3582ecf2e448e3e6acdf
6
+ metadata.gz: 89e66bc31760f4f109408eb2e838042ced0395483ac3293e8abe466eaa8940bca14b11693b43ac48db35811537291123f4631cdfb01d778850800954a621f675
7
+ data.tar.gz: 88d9af28a6059906f4afa40ff4d8794990e62ba008127b53e8a8019ee7eb76d501c6bd5783385ad1cbd7286f006bf7e0bd4e8b60f131bc498a1c80dca0b621ae
@@ -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(:TLSv1)
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
@@ -1,3 +1,3 @@
1
1
  module ApnsSimple
2
- VERSION = '0.5.1'
2
+ VERSION = '0.7.0'
3
3
  end
data/lib/apns_simple.rb CHANGED
@@ -3,4 +3,5 @@ require_relative 'apns_simple/notification'
3
3
  require_relative 'apns_simple/version'
4
4
 
5
5
  module ApnsSimple
6
+ class CertificateActivenessTimeError < StandardError; end
6
7
  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.1
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey Voronkov