certstepper 1.1.2 → 1.1.3
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/lib/certstepper.rb +137 -58
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b20b0c5bf7433d5abf30aa4a910a2ab58cf1d33
|
4
|
+
data.tar.gz: 535389d69c1aa5acd381e97c284617f5253ffe6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 206e93a58d081b5985f4c13df89fc296908b8fece244af2216bf595b8d50e9f663c92e81aa69823d43dafc303bc7d85d4c77e362ae87c361536a5bbd71e4187f
|
7
|
+
data.tar.gz: bfdee98c951cc1a91ea5f611a83fb31a486e8115df480179a7984e884d76433e43a70ea1c3605fa35e703aaf07a0023b098b62c2ea6911eb95bc77411cb6d2dd
|
data/lib/certstepper.rb
CHANGED
@@ -1,70 +1,142 @@
|
|
1
1
|
require "pathname"
|
2
2
|
require "fileutils"
|
3
|
+
require "json"
|
4
|
+
|
5
|
+
class String
|
6
|
+
def strip_control_characters()
|
7
|
+
chars.each_with_object("") do |char, str|
|
8
|
+
str << char unless char.ascii_only? and (char.ord < 32 or char.ord == 127)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def strip_control_and_extended_characters()
|
13
|
+
chars.each_with_object("") do |char, str|
|
14
|
+
str << char if char.ascii_only? and char.ord.between?(32,126)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
3
19
|
module CertStepper
|
4
20
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
self.getUserInput
|
47
|
-
self.copyToClipboard cert.profile_name
|
48
|
-
puts "name coppied : #{cert.profile_name}\n"
|
49
|
-
puts "\n7. move profile to destination from download. <press enter>"
|
50
|
-
self.getUserInput
|
51
|
-
mobileprovision_name = "#{cert.profile_name}.mobileprovision"
|
52
|
-
source_file = "#{File.expand_path('~')}/Downloads/#{mobileprovision_name}"
|
53
|
-
dest_file = "#{@@root_path}/#{cert.profile_name}/#{mobileprovision_name}"
|
54
|
-
if File.exist? source_file
|
55
|
-
FileUtils.mv source_file , dest_file
|
56
|
-
puts "#{mobileprovision_name} moved\n\n"
|
21
|
+
class Cert
|
22
|
+
attr_accessor :email
|
23
|
+
attr_accessor :password
|
24
|
+
attr_accessor :profile_id
|
25
|
+
attr_accessor :profile_name
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
def self.startStep
|
31
|
+
# if ARGV.length==0 || ARGV == nil
|
32
|
+
# puts "error: Parameter does not match,there is not any parameter"
|
33
|
+
# return nil
|
34
|
+
# end
|
35
|
+
|
36
|
+
|
37
|
+
file = File.open("#{File.expand_path('~')}/certstepper.log", "w")
|
38
|
+
file.write("#{ARGV}\n")
|
39
|
+
|
40
|
+
begin
|
41
|
+
if ARGV[0].start_with? "chrome-extension:"
|
42
|
+
finished = false
|
43
|
+
while !finished do
|
44
|
+
str = self.getUserInput[1..-1]
|
45
|
+
str =str.strip_control_characters
|
46
|
+
|
47
|
+
file.write("#{str}\n")
|
48
|
+
|
49
|
+
|
50
|
+
file.write "start parse #{str.class}\n"
|
51
|
+
my_hash = JSON.parse str
|
52
|
+
file.write("end parse#{my_hash}\n")
|
53
|
+
|
54
|
+
start_path = my_hash["start_path"]
|
55
|
+
profile_name = my_hash["name"]
|
56
|
+
if start_path
|
57
|
+
file.write("#start work \n")
|
58
|
+
self.startWorkByChromeExtension start_path , profile_name
|
59
|
+
finished = true
|
60
|
+
end
|
61
|
+
end
|
57
62
|
else
|
58
|
-
|
63
|
+
self.parseData ARGV[0]
|
64
|
+
self.startWork
|
59
65
|
end
|
60
66
|
|
61
|
-
|
62
|
-
|
67
|
+
rescue => e
|
68
|
+
f.write e.backtrace
|
69
|
+
end
|
70
|
+
|
71
|
+
|
72
|
+
file.close
|
73
|
+
end
|
74
|
+
|
75
|
+
def self.startWorkByChromeExtension(root_path,profile_name)
|
76
|
+
file = File.open("/Users/mac/Desktop/CertSimplify/some_file", "a")
|
77
|
+
console_root_path = root_path.gsub /[\s]/ , "\\ "
|
78
|
+
system("open #{console_root_path}")
|
79
|
+
self.createDir root_path + "/#{profile_name}"
|
80
|
+
self.dealCertByChrome root_path , profile_name
|
81
|
+
mobileprovision_name = "#{profile_name}.mobileprovision"
|
82
|
+
source_file = "#{File.expand_path('~')}/Downloads/#{mobileprovision_name}"
|
83
|
+
dest_file = "#{root_path}/#{profile_name}/#{mobileprovision_name}"
|
84
|
+
if File.exist? source_file
|
85
|
+
FileUtils.mv source_file , dest_file
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
|
90
|
+
def self.startWork
|
91
|
+
|
92
|
+
console_root_path = @@root_path.gsub /[\s]/ , "\\ "
|
93
|
+
open_dir ="open #{console_root_path}"
|
94
|
+
system("open #{console_root_path}")
|
95
|
+
puts "Apple Cert Create Stepper\n"
|
96
|
+
@@certs.each do |cert|
|
97
|
+
puts "----------- begin #{cert.profile_id} Cert ----------- \n"
|
98
|
+
self.createDir @@root_path + "/#{cert.profile_name}"
|
99
|
+
puts "1. copy email. <press enter>"
|
100
|
+
self.getUserInput
|
101
|
+
self.copyToClipboard cert.email
|
102
|
+
puts "email coppied : #{cert.email}\n"
|
103
|
+
puts "2. copy password. <press enter>"
|
104
|
+
self.getUserInput
|
105
|
+
self.copyToClipboard cert.password
|
106
|
+
puts "password coppied : #{cert.password}\n"
|
107
|
+
puts "3.import and export cert"
|
108
|
+
self.dealCert cert
|
109
|
+
puts "4. copy profile name. <press enter>"
|
110
|
+
self.getUserInput
|
111
|
+
self.copyToClipboard cert.profile_name
|
112
|
+
puts "name coppied : #{cert.profile_name}\n"
|
113
|
+
puts "\n5. copy profile id. <press enter>"
|
114
|
+
self.getUserInput
|
115
|
+
self.copyToClipboard cert.profile_id
|
116
|
+
puts "id coppied : #{cert.profile_id}"
|
117
|
+
puts "\n6. copy profile name. <press enter>"
|
118
|
+
self.getUserInput
|
119
|
+
self.copyToClipboard cert.profile_name
|
120
|
+
puts "name coppied : #{cert.profile_name}\n"
|
121
|
+
puts "\n7. move profile to destination from download. <press enter>"
|
122
|
+
self.getUserInput
|
123
|
+
mobileprovision_name = "#{cert.profile_name}.mobileprovision"
|
124
|
+
source_file = "#{File.expand_path('~')}/Downloads/#{mobileprovision_name}"
|
125
|
+
dest_file = "#{@@root_path}/#{cert.profile_name}/#{mobileprovision_name}"
|
126
|
+
if File.exist? source_file
|
127
|
+
FileUtils.mv source_file , dest_file
|
128
|
+
puts "#{mobileprovision_name} moved\n\n"
|
129
|
+
else
|
130
|
+
puts "#{mobileprovision_name} doesn't exist. Please download and move by yourself !\n\n"
|
131
|
+
end
|
132
|
+
|
133
|
+
end
|
134
|
+
end
|
63
135
|
|
64
|
-
def self.parseData
|
136
|
+
def self.parseData(start_path)
|
65
137
|
@@certs = Array.new
|
66
138
|
index = 0
|
67
|
-
file_name =
|
139
|
+
file_name = start_path
|
68
140
|
@@root_path = Pathname.new(file_name).parent.to_s
|
69
141
|
@@file_path
|
70
142
|
new_cert = nil
|
@@ -106,7 +178,7 @@ module CertStepper
|
|
106
178
|
|
107
179
|
def self.getUserInput
|
108
180
|
begin
|
109
|
-
|
181
|
+
return $stdin.gets
|
110
182
|
rescue => e
|
111
183
|
|
112
184
|
end
|
@@ -119,4 +191,11 @@ module CertStepper
|
|
119
191
|
system "security delete-keychain 123456"
|
120
192
|
end
|
121
193
|
|
194
|
+
def self.dealCertByChrome(root_path , profile_name)
|
195
|
+
system "security create-keychain -P 123456"
|
196
|
+
system "security add-trusted-cert -r unspecified -k 123456 #{File.expand_path('~')}/Downloads/ios_development.cer"
|
197
|
+
system "security export -k 123456 -t certs -f pkcs12 -o #{root_path}/#{profile_name}/cert.p12"
|
198
|
+
system "security delete-keychain 123456"
|
199
|
+
end
|
200
|
+
|
122
201
|
end
|