certstepper 1.2.5 → 1.2.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/certstepper.rb +45 -22
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 92294ef95830e84508b9d9663a6cbfd4f131e8cd
4
- data.tar.gz: 6fcfd86d3c84d05f138969afc58b4071c187fb15
3
+ metadata.gz: 15ed9c970cb45f334a6ce7f85b58433c16443ff4
4
+ data.tar.gz: a967238021d1624931bc1c445e1d881ada221ff6
5
5
  SHA512:
6
- metadata.gz: 0e9c6d77faddaced2822aadff16738451f05af3a5f519fd197b5fa296e43b228a67d6412b5319bc978a674042e4f16b20792342f14cc6f5c493eafb3dc71f0d7
7
- data.tar.gz: 82933992b77766d4736c5f41928e178191b2101fdaf659b84426d9ec69116607b9e9dfe1fcfdb874f07f39520bc1d8913ac1f6e79594563453a7349be0247efd
6
+ metadata.gz: 058d9ee1c07b797e70528fedabb5b3d8612fd885446caf9307cc2e5f92c9306a132355d176e0f8448e54ede2660e6ba4869c85cd6c9e2a9e05e472e0da14a981
7
+ data.tar.gz: efe19a13b7999f3752c2431e12ad297735ef4322a321e60c98768c55070cba898de0dca743b8e250c116df792afe680b022ed5c254e228705e11a4fb92a5fe4a
@@ -5,6 +5,7 @@ require "cert"
5
5
  require "sigh"
6
6
  require 'optparse'
7
7
  require 'colorize'
8
+ require 'openssl'
8
9
 
9
10
  class String
10
11
  def strip_control_characters()
@@ -127,6 +128,11 @@ module CertStepper
127
128
  system("open #{console_root_path}")
128
129
  puts "Apple Cert Create Stepper\n"
129
130
 
131
+ @@base_dir = "#{Dir.home}/Library/CertStepper"
132
+ if !Dir.exist? @@base_dir
133
+ Dir.mkdir @@base_dir
134
+ end
135
+
130
136
  failed_cert_array = []
131
137
 
132
138
  @@certs.each do |cert|
@@ -134,20 +140,24 @@ module CertStepper
134
140
 
135
141
  if !generateCertSuccessfully?(cert) || @options[:force]
136
142
 
137
- cert_path = console_root_path + "/#{cert.profile_name}"
138
- createDir cert_path
143
+ cert_path = @@base_dir + "/#{cert.profile_name}"
144
+ final_path = console_root_path + "/#{cert.profile_name}"
145
+ createDir final_path
146
+ if !Dir.exist? cert_path
147
+ Dir.mkdir cert_path
148
+ end
139
149
 
140
150
  keychain_entry = CredentialsManager::AccountManager.new(user:cert.email , password: cert.password)
141
151
  keychain_entry.add_to_keychain
142
152
 
143
153
 
144
- createKeychain cert_path
154
+ #createKeychain cert
145
155
  system "cert -u #{cert.email} -o #{cert_path} #{@options[:cert_type]}"
146
- dealCert cert , cert_path
156
+ dealCert cert , cert_path , final_path
147
157
 
148
158
 
149
159
  system "produce -u #{cert.email} -a #{cert.profile_id} --app_name #{cert.profile_name} --skip_itc"
150
- system "sigh -a #{cert.profile_id} -u #{cert.email} -o #{cert_path} #{@options[:profile_type]}"
160
+ system "sigh -a #{cert.profile_id} -u #{cert.email} -o #{final_path} #{@options[:profile_type]} -z"
151
161
  #system "sigh -a #{cert.profile_id} -u #{cert.email} -o #{cert_path} --adhoc"
152
162
 
153
163
 
@@ -174,11 +184,9 @@ module CertStepper
174
184
  def self.deleteUnusefulFile(de_path)
175
185
  console_de_path = de_path.gsub /[\s]/ , "\\ "
176
186
  Dir.entries(de_path).each do |file_name|
177
- if file_name.end_with? '.cer'
187
+ if file_name.end_with? '.pem'
178
188
  file_path = "#{de_path}/#{file_name}"
179
189
  system "rm #{console_de_path}/#{file_name}"
180
- system "rm #{console_de_path}/#{File.basename(file_path,'.*')}.p12"
181
- system "rm #{console_de_path}/#{File.basename(file_path,'.*')}.certSigningRequest"
182
190
  end
183
191
  end
184
192
 
@@ -186,23 +194,20 @@ module CertStepper
186
194
 
187
195
  def self.generateCertSuccessfully?(cert)
188
196
  cert_path = @@root_path + "/#{cert.profile_name}"
189
- puts cert_path
190
197
  is_p12_exist = false
191
- is_cer_exist = false
192
198
  is_provision_exist = false
193
199
  if File.exists? cert_path
194
200
  Dir.entries(cert_path).each do |file_name|
195
201
  if file_name.end_with? ".p12"
196
202
  is_p12_exist = true
197
- elsif file_name.end_with? ".cer"
198
- is_cer_exist = true
199
203
  elsif file_name.end_with? ".mobileprovision"
200
204
  is_provision_exist = true
201
205
  end
202
206
  end
203
207
  end
204
208
 
205
- return is_p12_exist && is_cer_exist && is_provision_exist
209
+
210
+ return is_p12_exist && is_provision_exist
206
211
  end
207
212
 
208
213
  def self.parseData(start_path)
@@ -260,19 +265,38 @@ module CertStepper
260
265
  end
261
266
  end
262
267
 
263
- def self.createKeychain(de_path)
264
- @keychain_path = File.expand_path "#{de_path}/CertTempleContainor"
265
- system "security create-keychain -p 123456 #{@keychain_path}"
268
+ def self.createKeychain(cert)
269
+
270
+ @@base_dir = "#{Dir.home}/Library/CertStepper"
271
+ if !Dir.exist? @@base_dir
272
+ Dir.mkdir @@base_dir
273
+ end
274
+ @keychain_path = File.expand_path "#{@@base_dir}/#{cert.email}#{@options[:cert_type]}"
275
+ if !Dir.exist? @keychain_path
276
+ system "security create-keychain -p '' #{@keychain_path}"
277
+ end
266
278
  end
267
279
 
268
- def self.dealCert(cert,de_path)
280
+ def self.dealCert(cert,de_path,final_path)
269
281
  console_de_path = de_path.gsub /[\s]/ , "\\ "
282
+ console_final_path = final_path.gsub /[\s]/ , "\\ "
270
283
  Dir.entries(de_path).each do |file_name|
271
284
  if file_name.end_with? '.cer'
272
285
  #system "security add-trusted-cert -r unspecified -k 123456 #{File.expand_path('~')}/Downloads/ios_development.cer"
273
- system "security import #{console_de_path}/#{file_name} -k #{@keychain_path} -T `which codesign`"
274
- system "security export -k #{@keychain_path} -t certs -f pkcs12 -P 123 -o #{console_de_path}/#{cert.profile_name}.p12"
275
- system "security delete-keychain #{@keychain_path}"
286
+ #system "security import #{console_de_path}/#{file_name} -k #{@keychain_path} -T `which codesign`"
287
+ #system "security export -k #{@keychain_path} -t certs -f pkcs12 -P 123 -o #{console_de_path}/#{cert.profile_name}.p12"
288
+ #system "security delete-keychain #{@keychain_path}"
289
+
290
+ cert_name = File.basename(file_name,File.extname(file_name))
291
+
292
+
293
+ cert_pem = "#{console_de_path}/#{cert_name}CERT.pem"
294
+ key_pem = "#{console_de_path}/#{cert_name}.p12"
295
+ merge_pem = "#{console_de_path}/#{cert_name}MER.pem"
296
+
297
+ system "openssl x509 -in #{console_de_path}/#{file_name} -inform der -out #{cert_pem}"
298
+ system "cat #{cert_pem} #{key_pem} > #{merge_pem}"
299
+ system "openssl pkcs12 -export -in #{merge_pem} -out #{console_final_path}/#{cert.profile_name}.p12 -passout pass:123"
276
300
 
277
301
  end
278
302
  end
@@ -283,7 +307,7 @@ module CertStepper
283
307
  system "security create-keychain -P 123456"
284
308
  system "security add-trusted-cert -r unspecified -k 123456 #{File.expand_path('~')}/Downloads/ios_development.cer"
285
309
  system "security export -k 123456 -t certs -f pkcs12 -o #{root_path}/#{profile_name}/cert.p12"
286
- system "security delete-keychain 123456"
310
+ #system "security delete-keychain 123456"
287
311
  end
288
312
 
289
313
 
@@ -295,4 +319,3 @@ module CertStepper
295
319
  end
296
320
 
297
321
  end
298
- puts "".colorize(:green)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: certstepper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.5
4
+ version: 1.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - chengkai
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-17 00:00:00.000000000 Z
11
+ date: 2016-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cert