pem 0.1.1 → 0.1.2

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: 3199e481394a8ed9de295154b203cc8b2cd95d40
4
- data.tar.gz: d9c81daffd5db67ecb6fa77814e42edb79db50e1
3
+ metadata.gz: 8b68718888e7043f9d2cf2fb97f318b900f44f09
4
+ data.tar.gz: ab1ac18480d341c687f4912ddd0c98620c6609ef
5
5
  SHA512:
6
- metadata.gz: 21dcfdae5c6a3f5db96c20cc4eaa130100c425174722be008f8e78abe5218bd7780d108ee93b19fccd3686d79d086c4aa2e714bd5cc5f3578519e6ad350b2c91
7
- data.tar.gz: 7f4de52bd47aa8e4422ec71d06ea22ff034e898830391c01be3ff322b787b157108e148398753dd8b53b018847f05c598bd1fb329677bbbb5c06666943661851
6
+ metadata.gz: 058c72a5c4c108f3404d8b0fcf2e90a4e67ba58782d5f34e7700dfaaa0e0b6f3d8a01346aaf98fa324829d537d9bb978bb512f1b87708a32e9dacd409c88e1bd
7
+ data.tar.gz: bb0c1b25082185d261a75568d52200ce8a59f0b52c180107f43fd8b8149b10dbe823ebc6494d071922a4c298716d455f75ddad1ec292d3c0dfbc54ae9c299d40
data/README.md CHANGED
@@ -23,7 +23,8 @@ Tired of manually creating and maintaining your push notification profiles? Tire
23
23
  ```PEM``` does all that for, just by running ```pem```.
24
24
 
25
25
  Follow the developer on Twitter: [@KrauseFx](https://twitter.com/KrauseFx)<br />
26
- Sebastian Mayr ([@sebmasterkde](https://twitter.com/sebmasterkde)) who implemented the download mechanism of signing certificates.
26
+ Sebastian Mayr ([@sebmasterkde](https://twitter.com/sebmasterkde)) who implemented the download mechanism of signing certificates
27
+ Alexander Schuch ([@schuchalexander](https://twitter.com/schuchalexander)) who automated the generation of the signing request
27
28
 
28
29
 
29
30
  -------
@@ -59,7 +60,8 @@ Yes, that's the whole command!
59
60
  This does the following:
60
61
 
61
62
  - Verifies the production push certificate looks alright
62
- - Download the certificate
63
+ - Renews the push certificate in case it's necessary
64
+ - Downloads the certificate
63
65
  - Generates a new ```.pem``` file in the current working directory, which you can upload to your server
64
66
 
65
67
  You can pass parameters like this:
@@ -71,7 +73,7 @@ In case you prefer environment variables:
71
73
 
72
74
  - ```PEM_USERNAME```
73
75
  - ```PEM_APP_IDENTIFIER```
74
- - ```PEM_CERT_SIGNING_REQUEST``` which is used, in case a new profile needs to be created
76
+ - ```PEM_CERT_SIGNING_REQUEST``` in case you want to pass your own signing request file
75
77
 
76
78
  # How does it work?
77
79
  There are 2 actions involved:
@@ -79,6 +81,7 @@ There are 2 actions involved:
79
81
  - Accessing the ```iOS Dev Center``` to download the latest ```aps_production.cer```. See: [developer_center.rb](https://github.com/KrauseFx/PEM/blob/master/lib/pem/developer_center.rb).
80
82
  - Generating all the necessary profiles and files to prepare the finished ```.pem``` file. See: [cert_manager.rb](https://github.com/KrauseFx/PEM/blob/master/lib/pem/cert_manager.rb).
81
83
  ```PEM``` will create a temporary keychain called ```PEM.keychain``` and use that to generate the necessary profiles. That means ```PEM``` will not pollute your default keychain.
84
+ - The ```.certSigningRequest``` file will be generated in [signing_request.rb](https://github.com/KrauseFx/PEM/blob/master/lib/pem/signing_request.rb)
82
85
 
83
86
 
84
87
  ## How is my password stored?
data/lib/pem.rb CHANGED
@@ -4,6 +4,7 @@ require 'pem/helper'
4
4
  require 'pem/dependency_checker'
5
5
  require 'pem/developer_center'
6
6
  require 'pem/cert_manager'
7
+ require 'pem/signing_request'
7
8
 
8
9
  # Third Party code
9
10
  require 'colored'
@@ -1,5 +1,6 @@
1
1
  require 'deliver/password_manager'
2
2
  require 'open-uri'
3
+ require 'openssl'
3
4
 
4
5
  require 'capybara'
5
6
  require 'capybara/poltergeist'
@@ -239,7 +240,7 @@ module PEM
239
240
  wait_for_elements(".button.small.center.back") # just to wait
240
241
 
241
242
  # Upload CSR file
242
- first(:xpath, "//input[@type='file']").set signing_request
243
+ first(:xpath, "//input[@type='file']").set PEM::SigningRequest.get_path
243
244
 
244
245
  click_next # "Generate"
245
246
 
@@ -252,26 +253,6 @@ module PEM
252
253
  click_on "Edit"
253
254
  end
254
255
 
255
- def signing_request
256
- return ENV["PEM_CERT_SIGNING_REQUEST"] if (ENV["PEM_CERT_SIGNING_REQUEST"] and File.exists?(ENV["PEM_CERT_SIGNING_REQUEST"]))
257
-
258
- files = Dir["./*.certSigningRequest"]
259
- if files.count == 1
260
- Helper.log.debug "Found a .certSigningRequest at the current folder. Using that."
261
- return files.first
262
- end
263
-
264
- path = nil
265
- while not path or not File.exists?path
266
- puts "There was no profile found. To create a new one, we need a .certSigningRequest file".yellow
267
- puts "To not be asked for a .certSigningRequest, PEM will automatically look for one in the current folder".yellow
268
- path = ask("Path to your .certSigningRequest file (including extension): ")
269
- puts "Could not find certSigningRequest file at path '#{path}'".red unless File.exists?path
270
- end
271
-
272
- return path
273
- end
274
-
275
256
 
276
257
  private
277
258
  def click_next
@@ -0,0 +1,35 @@
1
+ module PEM
2
+ class SigningRequest
3
+ def self.get_path
4
+ return ENV["PEM_CERT_SIGNING_REQUEST"] if (ENV["PEM_CERT_SIGNING_REQUEST"] and File.exists?(ENV["PEM_CERT_SIGNING_REQUEST"]))
5
+
6
+ # Check if there is one in the current directory
7
+ files = Dir["./*.certSigningRequest"]
8
+ if files.count == 1
9
+ Helper.log.info "Found a .certSigningRequest at the current folder. Using that."
10
+ return files.first
11
+ end
12
+
13
+ return self.generate
14
+ end
15
+
16
+ def self.generate
17
+ Helper.log.info "Couldn't find a signing certificate in the current folder. Creating one for you now.".green
18
+ @key = OpenSSL::PKey::RSA.new 2048
19
+
20
+ # Generate CSR
21
+ csr = OpenSSL::X509::Request.new
22
+ csr.version = 0
23
+ csr.subject = OpenSSL::X509::Name.new([
24
+ ['CN', "PEM", OpenSSL::ASN1::UTF8STRING]
25
+ ])
26
+ csr.public_key = @key.public_key
27
+ csr.sign @key, OpenSSL::Digest::SHA1.new
28
+
29
+ path = File.join(TMP_FOLDER, 'PEMCertificateSigningRequest.certSigningRequest')
30
+ File.write(path, csr.to_pem)
31
+ Helper.log.info "Successfully generated .certSigningRequest at path '#{path}'"
32
+ return path
33
+ end
34
+ end
35
+ end
data/lib/pem/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module PEM
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felix Krause
@@ -236,6 +236,7 @@ files:
236
236
  - lib/pem/dependency_checker.rb
237
237
  - lib/pem/developer_center.rb
238
238
  - lib/pem/helper.rb
239
+ - lib/pem/signing_request.rb
239
240
  - lib/pem/update_checker.rb
240
241
  - lib/pem/version.rb
241
242
  homepage: http://felixkrause.at