certstepper 1.1.4 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/certstepper.rb +115 -49
- metadata +65 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0037ea84791c538ca76c2c6023a07ee457551bc1
|
4
|
+
data.tar.gz: 246f6d20f6c1a43a8fad2ace118fed87f3777ff8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 212c55f435ed3b7a2f4dddb2cdfb739d9319d9acb66172968fbdd67e89f584f5b6a5dc90f1cc5f42cd2c289defab35d97add0cf3eac2f4c319441d61e3000acf
|
7
|
+
data.tar.gz: caf2b3ec14bb41ad8ae2b88148173dd4d527658c3c0a271b9f21bc69f43bde9d8b26f76904caa3022f255abf219c529ee1a4a14b33fca190abbabf0c53661002
|
data/lib/certstepper.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
require "pathname"
|
2
2
|
require "fileutils"
|
3
3
|
require "json"
|
4
|
+
require "cert"
|
5
|
+
require "sigh"
|
6
|
+
require 'optparse'
|
4
7
|
|
5
8
|
class String
|
6
9
|
def strip_control_characters()
|
@@ -28,13 +31,13 @@ module CertStepper
|
|
28
31
|
|
29
32
|
|
30
33
|
def self.startStep
|
31
|
-
|
34
|
+
# if ARGV.length==0 || ARGV == nil
|
32
35
|
# puts "error: Parameter does not match,there is not any parameter"
|
33
36
|
# return nil
|
34
37
|
# end
|
35
38
|
|
39
|
+
#self.logMessage("#{ARGV}\n")
|
36
40
|
|
37
|
-
self.logMessage("#{ARGV}\n")
|
38
41
|
|
39
42
|
begin
|
40
43
|
if ARGV[0].start_with? "chrome-extension:"
|
@@ -59,6 +62,38 @@ module CertStepper
|
|
59
62
|
end
|
60
63
|
end
|
61
64
|
else
|
65
|
+
|
66
|
+
check_xcode_select = `which xcode-select`.strip
|
67
|
+
if !File.exists? check_xcode_select
|
68
|
+
`xcode-select --install`
|
69
|
+
end
|
70
|
+
|
71
|
+
|
72
|
+
@options = {}
|
73
|
+
option_parser = OptionParser.new do |opts|
|
74
|
+
opts.banner = "certstepper File_Path [Options]命令行生成证书和配置文件!\n文件的内容:三行一个循环,依次是开发者账号、密码、唯一标识"
|
75
|
+
@options[:cert_type] = ""
|
76
|
+
@options[:profile_type] = "--adhoc"
|
77
|
+
@options[:force] = false
|
78
|
+
|
79
|
+
opts.on('-t cert_type','--type cert_type','生成证书和配置文件的类型') do |value|
|
80
|
+
if value.start_with? 'ad'
|
81
|
+
@options[:cert_type] = ""
|
82
|
+
@options[:profile_type] = "--adhoc"
|
83
|
+
elsif value.start_with? 'dev'
|
84
|
+
@options[:cert_type] = "--development"
|
85
|
+
@options[:profile_type] = "--development"
|
86
|
+
elsif value.start_with? 'dis'
|
87
|
+
@options[:cert_type] = ""
|
88
|
+
@options[:profile_type] = ""
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
opts.on('-f', '--force', '强制重新获取证书,默认生成成功后不再重新获取') do
|
93
|
+
@options[:force] = true
|
94
|
+
end
|
95
|
+
end.parse!
|
96
|
+
|
62
97
|
self.parseData ARGV[0]
|
63
98
|
self.startWork
|
64
99
|
end
|
@@ -85,50 +120,67 @@ module CertStepper
|
|
85
120
|
end
|
86
121
|
|
87
122
|
def self.startWork
|
88
|
-
|
123
|
+
puts "总共要生成#{@@certs.length}个证书"
|
89
124
|
console_root_path = @@root_path.gsub /[\s]/ , "\\ "
|
90
125
|
open_dir ="open #{console_root_path}"
|
91
126
|
system("open #{console_root_path}")
|
92
127
|
puts "Apple Cert Create Stepper\n"
|
128
|
+
|
129
|
+
failed_cert_array = []
|
130
|
+
|
93
131
|
@@certs.each do |cert|
|
94
132
|
puts "----------- begin #{cert.profile_id} Cert ----------- \n"
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
if File.exist? source_file
|
124
|
-
FileUtils.mv source_file , dest_file
|
125
|
-
puts "#{mobileprovision_name} moved\n\n"
|
126
|
-
else
|
127
|
-
puts "#{mobileprovision_name} doesn't exist. Please download and move by yourself !\n\n"
|
128
|
-
end
|
133
|
+
|
134
|
+
if !generateCertSuccessfully?(cert) || @options[:force]
|
135
|
+
|
136
|
+
cert_path = console_root_path + "/#{cert.profile_name}"
|
137
|
+
createDir cert_path
|
138
|
+
|
139
|
+
keychain_entry = CredentialsManager::AccountManager.new(user:cert.email , password: cert.password)
|
140
|
+
keychain_entry.add_to_keychain
|
141
|
+
|
142
|
+
|
143
|
+
createKeychain cert_path
|
144
|
+
system "cert -u #{cert.email} -o #{cert_path} #{@options[:cert_type]}"
|
145
|
+
dealCert cert_path
|
146
|
+
|
147
|
+
|
148
|
+
system "produce -u #{cert.email} -a #{cert.profile_id} --app_name #{cert.profile_name} --skip_itc"
|
149
|
+
system "sigh -a #{cert.profile_id} -u #{cert.email} -o #{cert_path} #{@options[:profile_type]}"
|
150
|
+
#system "sigh -a #{cert.profile_id} -u #{cert.email} -o #{cert_path} --adhoc"
|
151
|
+
|
152
|
+
if !generateCertSuccessfully? cert
|
153
|
+
failed_cert_array << cert.email
|
154
|
+
end
|
155
|
+
|
156
|
+
end
|
157
|
+
|
158
|
+
|
159
|
+
failed_content = "以下账号的证书和配置文件创建失败:\n" + failed_cert_array.join("\n") + "请重新尝试执行命令,如果多次不成功,请检查账号密码的正确性!"
|
160
|
+
puts failed_content
|
129
161
|
|
130
162
|
end
|
163
|
+
|
164
|
+
|
131
165
|
end
|
166
|
+
|
167
|
+
def self.generateCertSuccessfully?(cert)
|
168
|
+
cert_path = @@root_path + "/#{cert.profile_name}"
|
169
|
+
is_p12_exist = false
|
170
|
+
is_cer_exist = false
|
171
|
+
is_provision_exist = false
|
172
|
+
Dir.entries(de_path).each do |file_name|
|
173
|
+
if file_name.end_with? ".p12"
|
174
|
+
is_p12_exist = true
|
175
|
+
elsif file_name.end_with? ".cer"
|
176
|
+
is_cer_exist = true
|
177
|
+
elsif file_name.end_with? ".mobileprovision"
|
178
|
+
is_provision_exist = true
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
return is_p12_exist && is_cer_exist && is_provision_exist
|
183
|
+
end
|
132
184
|
|
133
185
|
def self.parseData(start_path)
|
134
186
|
@@certs = Array.new
|
@@ -154,9 +206,7 @@ module CertStepper
|
|
154
206
|
new_cert.password = line_content.strip
|
155
207
|
when 2
|
156
208
|
new_cert.profile_id = line_content.strip
|
157
|
-
|
158
|
-
new_cert.profile_name = comp if comp =~ /\b\w?\d+\b/
|
159
|
-
end
|
209
|
+
new_cert.profile_name = line_content.strip.scan(/\b\w?\d+\b/).join ""
|
160
210
|
end
|
161
211
|
index+=1
|
162
212
|
end
|
@@ -170,7 +220,12 @@ module CertStepper
|
|
170
220
|
end
|
171
221
|
|
172
222
|
def self.createDir(filePath)
|
173
|
-
|
223
|
+
if !Dir.exist? filePath
|
224
|
+
Dir.mkdir filePath
|
225
|
+
else
|
226
|
+
FileUtils.rm_r filePath
|
227
|
+
Dir.mkdir filePath
|
228
|
+
end
|
174
229
|
end
|
175
230
|
|
176
231
|
def self.getUserInput
|
@@ -181,11 +236,21 @@ module CertStepper
|
|
181
236
|
end
|
182
237
|
end
|
183
238
|
|
184
|
-
def self.
|
185
|
-
|
186
|
-
system "security
|
187
|
-
|
188
|
-
|
239
|
+
def self.createKeychain(de_path)
|
240
|
+
@keychain_path = File.expand_path "#{de_path}/CertTempleContainor"
|
241
|
+
system "security create-keychain -p 123456 #{@keychain_path}"
|
242
|
+
end
|
243
|
+
|
244
|
+
def self.dealCert(de_path)
|
245
|
+
console_de_path = de_path.gsub /[\s]/ , "\\ "
|
246
|
+
Dir.entries(de_path).each do |file_name|
|
247
|
+
if file_name.end_with? '.cer'
|
248
|
+
#system "security add-trusted-cert -r unspecified -k 123456 #{File.expand_path('~')}/Downloads/ios_development.cer"
|
249
|
+
system "security import #{de_path}/#{file_name} -k #{@keychain_path}"
|
250
|
+
system "security export -k #{@keychain_path} -t certs -f pkcs12 -P 123 -o #{console_de_path}/cert.p12"
|
251
|
+
system "security delete-keychain #{@keychain_path}"
|
252
|
+
end
|
253
|
+
end
|
189
254
|
end
|
190
255
|
|
191
256
|
def self.dealCertByChrome(root_path , profile_name)
|
@@ -197,9 +262,10 @@ module CertStepper
|
|
197
262
|
|
198
263
|
|
199
264
|
def self.logMessage(message)
|
200
|
-
|
201
|
-
file.
|
202
|
-
file.
|
265
|
+
puts message
|
266
|
+
#file = File.open("#{File.expand_path('~')}/certstepper.log", "w+")
|
267
|
+
#file.write message
|
268
|
+
#file.close
|
203
269
|
end
|
204
270
|
|
205
271
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: certstepper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- chengkai
|
@@ -9,7 +9,67 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2015-07-20 00:00:00.000000000 Z
|
12
|
-
dependencies:
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: cert
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.2'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.2.8
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.2'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.2.8
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: sigh
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '1.3'
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 1.3.0
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '1.3'
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 1.3.0
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: produce
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - "~>"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '1.1'
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 1.1.1
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '1.1'
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: 1.1.1
|
13
73
|
description: create ios dev cert simple
|
14
74
|
email: chengkai@1853.com
|
15
75
|
executables:
|
@@ -28,17 +88,17 @@ require_paths:
|
|
28
88
|
- lib
|
29
89
|
required_ruby_version: !ruby/object:Gem::Requirement
|
30
90
|
requirements:
|
31
|
-
- -
|
91
|
+
- - ">="
|
32
92
|
- !ruby/object:Gem::Version
|
33
93
|
version: '0'
|
34
94
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
95
|
requirements:
|
36
|
-
- -
|
96
|
+
- - ">="
|
37
97
|
- !ruby/object:Gem::Version
|
38
98
|
version: '0'
|
39
99
|
requirements: []
|
40
100
|
rubyforge_project:
|
41
|
-
rubygems_version: 2.4.
|
101
|
+
rubygems_version: 2.4.5
|
42
102
|
signing_key:
|
43
103
|
specification_version: 4
|
44
104
|
summary: cert simplefy
|