push_package 0.1.3 → 0.2.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 +4 -4
- data/.travis.yml +1 -0
- data/README.md +5 -1
- data/lib/push_package.rb +7 -2
- data/lib/push_package/version.rb +1 -1
- data/spec/fixtures/intermediate.crt +0 -0
- data/spec/push_package_spec.rb +31 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc872d152c7700bd4e120c861fc8a41ae4799d43
|
4
|
+
data.tar.gz: a9d3e1266b6f6a7ec9e4a5cf3ad04e58e84de68e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e527193e4a22d908ba95ece1deb457501dd3c720642d498d6dfe45d98ab98fb3bc55c1bdf5bae0e0b448837a7c6f048217e403e5f35a36fab2c7ed85f5d6d86b
|
7
|
+
data.tar.gz: 57c8e51d968c9de7728722c14b4a602e34d2037aea375c47ee1f8c1f449246cbc4352676a9a810aa7435d09ab8ae829039acafd60dc00f1d6c104aaf02a6d7fb
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -21,6 +21,9 @@ This gem provides a Ruby library and command line tool for creating a push packa
|
|
21
21
|
|
22
22
|
You must obtain a Website Push certificate from apple which requires a iOS developer license or a Mac developer license
|
23
23
|
|
24
|
+
[Starting February 2016](https://developer.apple.com/support/certificates/expiration/), you will also need a copy of the
|
25
|
+
Apple intermediate cert ([WWDR Certificate, expiring 02/07/23](https://developer.apple.com/certificationauthority/AppleWWDRCA.cer))
|
26
|
+
|
24
27
|
```ruby
|
25
28
|
require 'push_package'
|
26
29
|
|
@@ -35,7 +38,8 @@ website_params = {
|
|
35
38
|
|
36
39
|
iconset_path = 'path/to/iconset'
|
37
40
|
certificate = 'path/to/certificate.p12' # or certificate_string
|
38
|
-
|
41
|
+
intermediate_cert = 'path/to/AppleWWDRCA.cer'
|
42
|
+
package = PushPackage.new(website_params, iconset_path, certificate, 'optional cert password', intermediate_cert)
|
39
43
|
package.save('path/to/save')
|
40
44
|
|
41
45
|
```
|
data/lib/push_package.rb
CHANGED
@@ -15,7 +15,7 @@ class PushPackage
|
|
15
15
|
|
16
16
|
attr_reader :p12
|
17
17
|
|
18
|
-
def initialize(website_params, iconset_path, certificate, password = nil)
|
18
|
+
def initialize(website_params, iconset_path, certificate, password = nil, intermediate_cert = nil)
|
19
19
|
raise InvalidParameterError unless valid_website_params?(website_params)
|
20
20
|
raise InvalidIconsetError unless valid_iconset?(iconset_path)
|
21
21
|
raise ArgumentError unless certificate
|
@@ -35,6 +35,11 @@ class PushPackage
|
|
35
35
|
cert_data.force_encoding(Encoding::ASCII_8BIT)
|
36
36
|
end
|
37
37
|
@p12 = OpenSSL::PKCS12.new(cert_data, password)
|
38
|
+
|
39
|
+
if intermediate_cert
|
40
|
+
intermediate_cert_data = File.read(intermediate_cert)
|
41
|
+
@extra_certs = [OpenSSL::X509::Certificate.new(intermediate_cert_data)]
|
42
|
+
end
|
38
43
|
end
|
39
44
|
|
40
45
|
def save(output_path = nil)
|
@@ -87,7 +92,7 @@ class PushPackage
|
|
87
92
|
|
88
93
|
def signature
|
89
94
|
#use the certificate to create a pkcs7 detached signature
|
90
|
-
OpenSSL::PKCS7::sign(@p12.certificate, @p12.key, manifest_data,
|
95
|
+
OpenSSL::PKCS7::sign(@p12.certificate, @p12.key, manifest_data, @extra_certs, OpenSSL::PKCS7::BINARY | OpenSSL::PKCS7::DETACHED)
|
91
96
|
end
|
92
97
|
|
93
98
|
def manifest_data
|
data/lib/push_package/version.rb
CHANGED
Binary file
|
data/spec/push_package_spec.rb
CHANGED
@@ -73,6 +73,12 @@ describe PushPackage do
|
|
73
73
|
PushPackage.new(website_params, iconset_path, '/some/file.p12')
|
74
74
|
end.must_raise(Errno::ENOENT)
|
75
75
|
end
|
76
|
+
|
77
|
+
it 'should support intermediate_cert path' do
|
78
|
+
lambda do
|
79
|
+
PushPackage.new(website_params, iconset_path, certificate, 'testing', '/some/file.crt')
|
80
|
+
end.must_raise(Errno::ENOENT)
|
81
|
+
end
|
76
82
|
end
|
77
83
|
|
78
84
|
describe 'website params with string keys' do
|
@@ -93,6 +99,12 @@ describe PushPackage do
|
|
93
99
|
PushPackage.new(website_params_symbol_keys, iconset_path, '/some/file.p12')
|
94
100
|
end.must_raise(Errno::ENOENT)
|
95
101
|
end
|
102
|
+
|
103
|
+
it 'should support intermediate_cert path' do
|
104
|
+
lambda do
|
105
|
+
PushPackage.new(website_params_symbol_keys, iconset_path, certificate, 'testing', '/some/file.crt')
|
106
|
+
end.must_raise(Errno::ENOENT)
|
107
|
+
end
|
96
108
|
end
|
97
109
|
end
|
98
110
|
|
@@ -173,5 +185,24 @@ describe PushPackage do
|
|
173
185
|
OpenSSL::PKCS7::DETACHED
|
174
186
|
).must_equal true
|
175
187
|
end
|
188
|
+
|
189
|
+
it 'should have no extra certs in signature' do
|
190
|
+
extracted_package.must_include('signature')
|
191
|
+
signature = File.read(tmp_path + '/signature')
|
192
|
+
p7 = OpenSSL::PKCS7.new(signature)
|
193
|
+
p7.certificates().size.must_equal 1
|
194
|
+
end
|
195
|
+
|
196
|
+
describe 'when intermediate_cert given' do
|
197
|
+
let(:intermediate_cert) { File.open(fixture_path('intermediate.crt')) }
|
198
|
+
let(:push_package) { PushPackage.new(website_params, iconset_path, certificate, 'testing', intermediate_cert) }
|
199
|
+
|
200
|
+
it 'should have one extra cert in signature' do
|
201
|
+
extracted_package.must_include('signature')
|
202
|
+
signature = File.read(tmp_path + '/signature')
|
203
|
+
p7 = OpenSSL::PKCS7.new(signature)
|
204
|
+
p7.certificates().size.must_equal 2
|
205
|
+
end
|
206
|
+
end
|
176
207
|
end
|
177
208
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: push_package
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan Natchev
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2016-01-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rubyzip
|
@@ -92,6 +92,7 @@ files:
|
|
92
92
|
- spec/fixtures/iconset/icon_16x16@2x.png
|
93
93
|
- spec/fixtures/iconset/icon_32x32.png
|
94
94
|
- spec/fixtures/iconset/icon_32x32@2x.png
|
95
|
+
- spec/fixtures/intermediate.crt
|
95
96
|
- spec/fixtures/localhost.crt
|
96
97
|
- spec/fixtures/localhost.csr
|
97
98
|
- spec/fixtures/localhost.key
|
@@ -120,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
121
|
version: '0'
|
121
122
|
requirements: []
|
122
123
|
rubyforge_project:
|
123
|
-
rubygems_version: 2.
|
124
|
+
rubygems_version: 2.5.1
|
124
125
|
signing_key:
|
125
126
|
specification_version: 4
|
126
127
|
summary: A gem for creating Safari push notification push packages.
|
@@ -131,6 +132,7 @@ test_files:
|
|
131
132
|
- spec/fixtures/iconset/icon_16x16@2x.png
|
132
133
|
- spec/fixtures/iconset/icon_32x32.png
|
133
134
|
- spec/fixtures/iconset/icon_32x32@2x.png
|
135
|
+
- spec/fixtures/intermediate.crt
|
134
136
|
- spec/fixtures/localhost.crt
|
135
137
|
- spec/fixtures/localhost.csr
|
136
138
|
- spec/fixtures/localhost.key
|