pem 0.1.4 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7edf95975cba2399652b2744959bfed9685c4294
4
- data.tar.gz: e389b47259d1fbfd6aaa36287a5187b697c99784
3
+ metadata.gz: b953613039c526d03c52b0341dfbd8b235302e7d
4
+ data.tar.gz: 24327d42b6d028ce77a15fcefcdbb2e8dad66751
5
5
  SHA512:
6
- metadata.gz: 0bc479d395be07e1d7614b55b6a4c2ea5a81da9fb87f911c46debb687432c2e0cf41ba03a084750689f7f40b31a5e68aeb1c6fc321529a253262462cf943548d
7
- data.tar.gz: eb66fe2cc46d49e55571abb17d6803d9e0b558132ddc91ca845d123f4ee5f147e871e29b641be52ad1e498ddd4996c39dfab87470f2fe4d783d6a9d1f1589a40
6
+ metadata.gz: 3d4de449003920eb1594f7fc546ba97c793a26b1768e3829863e69811d1a1e02e726aa77def4f6599fff9cac8c5ab6dbc7370b9516a9181dc7279a92cd4242ef
7
+ data.tar.gz: 5d436da8f8de0a09a673cf187f201b8e09200211e4dd6ef63aad7cba961949dd073e9a3f0ca1c46c1913689a9a32abf37d764ed203cb53cff940a576420a9370
data/README.md CHANGED
@@ -29,12 +29,14 @@ Alexander Schuch ([@schuchalexander](https://twitter.com/schuchalexander)) who a
29
29
 
30
30
 
31
31
  -------
32
- [Features](#features) •
33
- [Installation](#installation) •
34
- [Usage](#usage) •
35
- [How does it work?](#how-does-it-work) •
36
- [Tips](#tips) •
37
- [Need help?](#need-help)
32
+ <p align="center">
33
+ <a href="#features">Features</a> &bull;
34
+ <a href="#installation">Installation</a> &bull;
35
+ <a href="#usage">Usage</a> &bull;
36
+ <a href="#how-does-it-work">How does it work?</a> &bull;
37
+ <a href="#tips">Tips</a> &bull;
38
+ <a href="#need-help">Need help?</a>
39
+ </p>
38
40
 
39
41
  -------
40
42
 
@@ -84,7 +86,6 @@ In case you prefer environment variables:
84
86
 
85
87
  - ```PEM_USERNAME```
86
88
  - ```PEM_APP_IDENTIFIER```
87
- - ```PEM_CERT_SIGNING_REQUEST``` in case you want to pass your own signing request file
88
89
 
89
90
  # How does it work?
90
91
  There are 2 actions involved:
@@ -9,34 +9,21 @@ module PEM
9
9
 
10
10
  dev = PEM::DeveloperCenter.new
11
11
 
12
- keychain = "PEM.keychain"
13
-
14
12
  cert_file = dev.fetch_cer_file(app_identifier, production)
15
- rsa_file = [TMP_FOLDER, 'myrsa'].join('/')
16
-
17
- previous_keychain = command("security default-keychain")
18
-
19
-
20
-
21
- command("security create-keychain -p '' #{keychain}") # create a new keychain for this type
13
+ rsa_file = File.join(TMP_FOLDER, 'private_key.key')
22
14
 
23
- command("security list-keychains -d user -s #{keychain}") # add it to the list of keychains
24
-
25
- command("openssl genrsa -out '#{rsa_file}' 2048") # generate a new RSA file
26
- command("security import '#{rsa_file}' -P '' -k #{keychain}") # import the RSA file into the Keychain
27
- command("security import '#{cert_file}' -k #{keychain}") # import the profile from Apple into the Keychain
28
-
29
- p12_file = [TMP_FOLDER, "push_prod.12"].join('/')
30
-
31
- command("security export -k '#{keychain}' -t all -f pkcs12 -P '' -o #{p12_file}") # export code signing identity
15
+ pem_temp = File.join(TMP_FOLDER, 'pem_temp.pem')
32
16
 
33
17
  certificate_type = (production ? 'production' : 'development')
34
- pem_file = [TMP_FOLDER, "#{certificate_type}_#{app_identifier}.pem"].join('')
35
- command("openssl pkcs12 -passin pass: -nodes -in #{p12_file} -out #{pem_file}")
36
18
 
37
- command("security delete-keychain #{keychain}")
38
19
 
39
- command("security list-keychains -d user -s #{previous_keychain}") # switch back to default keychain
20
+ pem_file = File.join(TMP_FOLDER, "#{certificate_type}_#{app_identifier}.pem")
21
+ command("openssl x509 -inform der -in '#{cert_file}' -out #{pem_temp}")
22
+ content = File.read(pem_temp) + File.read(rsa_file)
23
+ File.write(pem_file, content)
24
+
25
+
26
+ File.delete(rsa_file)
40
27
 
41
28
  return pem_file
42
29
  end
@@ -179,33 +179,9 @@ module PEM
179
179
  if not download_button
180
180
  Helper.log.warn "Push for app '#{app_identifier}' is enabled, but there is no #{certificate_type} certificate yet."
181
181
  create_push_for_app(app_identifier, production)
182
-
183
- download_button = find_download_button(section_title)
184
- raise "Could not find download button for #{section_title}. Check out: '#{current_url}'" unless download_button
182
+ else
183
+ raise "Could not create a new push profile for app '#{app_identifier}'. There is already a profile active.".red
185
184
  end
186
-
187
-
188
- Helper.log.info "Going to download the latest profile"
189
-
190
- # It is enabled, now just download it
191
- # Taken from http://stackoverflow.com/a/17111206/445598
192
- sleep 2
193
-
194
- host = Capybara.current_session.current_host
195
- url = download_button['href']
196
- url = [host, url].join('')
197
-
198
- myacinfo = page.driver.cookies['myacinfo'].value # some magic Apple, which is required for the profile download
199
- data = open(url, {'Cookie' => "myacinfo=#{myacinfo}"}).read
200
-
201
- raise "Something went wrong when downloading the certificate" unless data
202
-
203
- path = "#{TMP_FOLDER}/aps_#{certificate_type}_#{app_identifier}.cer"
204
- File.write(path, data)
205
-
206
- Helper.log.info "Successfully downloaded latest .cer file."
207
- return path
208
-
209
185
  rescue Exception => ex
210
186
  error_occured(ex)
211
187
  end
@@ -252,8 +228,30 @@ module PEM
252
228
  sleep 2
253
229
  end
254
230
 
255
- open_app_page(app_identifier)
256
- click_on "Edit"
231
+ certificate_type = (production ? 'production' : 'development')
232
+
233
+ # Download the newly created certificate
234
+ Helper.log.info "Going to download the latest profile"
235
+
236
+ # It is enabled, now just download it
237
+ sleep 2
238
+
239
+ download_button = first(".button.small.blue")
240
+ host = Capybara.current_session.current_host
241
+ url = download_button['href']
242
+ url = [host, url].join('')
243
+ puts url
244
+
245
+ myacinfo = page.driver.cookies['myacinfo'].value # some magic Apple, which is required for the profile download
246
+ data = open(url, {'Cookie' => "myacinfo=#{myacinfo}"}).read
247
+
248
+ raise "Something went wrong when downloading the certificate" unless data
249
+
250
+ path = "#{TMP_FOLDER}/aps_#{certificate_type}_#{app_identifier}.cer"
251
+ File.write(path, data)
252
+
253
+ Helper.log.info "Successfully downloaded latest .cer file."
254
+ return path
257
255
  end
258
256
 
259
257
 
@@ -1,16 +1,7 @@
1
1
  module PEM
2
2
  class SigningRequest
3
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
4
+ self.generate
14
5
  end
15
6
 
16
7
  def self.generate
@@ -28,6 +19,8 @@ module PEM
28
19
 
29
20
  path = File.join(TMP_FOLDER, 'PEMCertificateSigningRequest.certSigningRequest')
30
21
  File.write(path, csr.to_pem)
22
+ File.write(File.join(TMP_FOLDER, 'private_key.key'), @key)
23
+
31
24
  Helper.log.info "Successfully generated .certSigningRequest at path '#{path}'"
32
25
  return path
33
26
  end
@@ -1,3 +1,3 @@
1
1
  module PEM
2
- VERSION = "0.1.4"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felix Krause
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-26 00:00:00.000000000 Z
11
+ date: 2014-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: security
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ~>
32
- - !ruby/object:Gem::Version
33
- version: 0.1.3
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ~>
39
- - !ruby/object:Gem::Version
40
- version: 0.1.3
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: highline
43
29
  requirement: !ruby/object:Gem::Requirement