apple_certs_info 0.1.8 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.idea/apple_certs_info.iml +6 -6
- data/Gemfile.lock +3 -3
- data/README.md +2 -2
- data/apple_certs_info.gemspec +2 -2
- data/lib/apple_certs_info.rb +91 -65
- data/lib/apple_certs_info/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1809b2104213abf8d06e1e9bcae8ee4716889623b5aafd61b3e30a0aaad0ad5
|
4
|
+
data.tar.gz: d9b149f6bdecee70877c0a68fd7ec22733f6fb916ae2f7be23afa29e8b8356f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d689a92582e1f4537c97daa5d5acd06b7e2a2b45154e0cbf350bf1d52aa17cf43cda44c9b8a0fa63f4562cc4b27583c821aca45f96d6ed6291d0a33d1f1cb57f
|
7
|
+
data.tar.gz: 1377dc070866eca0cf675eadd5f270e301aaee72b83c4925a376f44943488d26ddeb8dde4dd1d63ed35a217374f3a344eec2406d89931b1da44fdf5dfa4da4b3
|
data/.idea/apple_certs_info.iml
CHANGED
@@ -108,28 +108,28 @@
|
|
108
108
|
</library>
|
109
109
|
</orderEntry>
|
110
110
|
<orderEntry type="module-library">
|
111
|
-
<library name="rspec-mocks (vbundled(3.10.
|
111
|
+
<library name="rspec-mocks (vbundled(3.10.2)) [path][gem]" type="rubylib">
|
112
112
|
<properties>
|
113
113
|
<option name="version" value="4" />
|
114
114
|
</properties>
|
115
115
|
<CLASSES>
|
116
|
-
<root url="file://$MODULE_DIR$/vendor/bundle/ruby/2.6.0/gems/rspec-mocks-3.10.
|
116
|
+
<root url="file://$MODULE_DIR$/vendor/bundle/ruby/2.6.0/gems/rspec-mocks-3.10.2/lib" />
|
117
117
|
</CLASSES>
|
118
118
|
<SOURCES>
|
119
|
-
<root url="file://$MODULE_DIR$/vendor/bundle/ruby/2.6.0/gems/rspec-mocks-3.10.
|
119
|
+
<root url="file://$MODULE_DIR$/vendor/bundle/ruby/2.6.0/gems/rspec-mocks-3.10.2/lib" />
|
120
120
|
</SOURCES>
|
121
121
|
</library>
|
122
122
|
</orderEntry>
|
123
123
|
<orderEntry type="module-library">
|
124
|
-
<library name="rspec-support (vbundled(3.10.
|
124
|
+
<library name="rspec-support (vbundled(3.10.2)) [path][gem]" type="rubylib">
|
125
125
|
<properties>
|
126
126
|
<option name="version" value="4" />
|
127
127
|
</properties>
|
128
128
|
<CLASSES>
|
129
|
-
<root url="file://$MODULE_DIR$/vendor/bundle/ruby/2.6.0/gems/rspec-support-3.10.
|
129
|
+
<root url="file://$MODULE_DIR$/vendor/bundle/ruby/2.6.0/gems/rspec-support-3.10.2/lib" />
|
130
130
|
</CLASSES>
|
131
131
|
<SOURCES>
|
132
|
-
<root url="file://$MODULE_DIR$/vendor/bundle/ruby/2.6.0/gems/rspec-support-3.10.
|
132
|
+
<root url="file://$MODULE_DIR$/vendor/bundle/ruby/2.6.0/gems/rspec-support-3.10.2/lib" />
|
133
133
|
</SOURCES>
|
134
134
|
</library>
|
135
135
|
</orderEntry>
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
apple_certs_info (0.
|
4
|
+
apple_certs_info (0.3.2)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -17,10 +17,10 @@ GEM
|
|
17
17
|
rspec-expectations (3.10.1)
|
18
18
|
diff-lcs (>= 1.2.0, < 2.0)
|
19
19
|
rspec-support (~> 3.10.0)
|
20
|
-
rspec-mocks (3.10.
|
20
|
+
rspec-mocks (3.10.2)
|
21
21
|
diff-lcs (>= 1.2.0, < 2.0)
|
22
22
|
rspec-support (~> 3.10.0)
|
23
|
-
rspec-support (3.10.
|
23
|
+
rspec-support (3.10.2)
|
24
24
|
|
25
25
|
PLATFORMS
|
26
26
|
ruby
|
data/README.md
CHANGED
@@ -40,7 +40,7 @@ AppleCertsInfo.certificate_distribution_list_limit_days_for(days: 10)
|
|
40
40
|
|
41
41
|
## Contributing
|
42
42
|
|
43
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
43
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/tarappo/apple_certs_info. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/tarappo/apple_certs_info/blob/master/CODE_OF_CONDUCT.md).
|
44
44
|
|
45
45
|
|
46
46
|
## License
|
@@ -49,4 +49,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
49
49
|
|
50
50
|
## Code of Conduct
|
51
51
|
|
52
|
-
Everyone interacting in the AppleCertsInfo project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
52
|
+
Everyone interacting in the AppleCertsInfo project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/tarappo/apple_certs_info/blob/master/CODE_OF_CONDUCT.md).
|
data/apple_certs_info.gemspec
CHANGED
@@ -3,13 +3,13 @@ require_relative 'lib/apple_certs_info/version'
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = "apple_certs_info"
|
5
5
|
spec.version = AppleCertsInfo::VERSION
|
6
|
-
spec.authors = ["
|
6
|
+
spec.authors = ["tarappo"]
|
7
7
|
spec.email = ["tarappo@gmail.com"]
|
8
8
|
|
9
9
|
spec.summary = %q{Apple Certificate files and Provisioning Profile information.}
|
10
10
|
spec.homepage = "https://github.com/tarappo/apple_certs_info"
|
11
11
|
spec.license = "MIT"
|
12
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 2.
|
12
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
|
13
13
|
|
14
14
|
spec.metadata["homepage_uri"] = spec.homepage
|
15
15
|
spec.metadata["source_code_uri"] = "https://github.com/tarappo/apple_certs_info"
|
data/lib/apple_certs_info.rb
CHANGED
@@ -15,76 +15,61 @@ module AppleCertsInfo
|
|
15
15
|
|
16
16
|
# Check Certificate file for iPhone Developer /Apple Development in the KeyChain
|
17
17
|
# @param days: limit days
|
18
|
+
# @return:
|
19
|
+
# expire_datetime: deadline
|
20
|
+
# limit_days: limit days
|
21
|
+
# cname: CN
|
18
22
|
def self.certificate_development_list_limit_days_for(days:)
|
19
23
|
raise "do not set days param" if days.nil?
|
20
|
-
|
24
|
+
filtering_limit_days_for(list: certificate_development_list.uniq, days: days)
|
21
25
|
end
|
22
26
|
|
23
27
|
# Check Certificate file for iPhone/Apple Distribution in the KeyChain
|
28
|
+
# @param days: limit days
|
29
|
+
# @return:
|
30
|
+
# expire_datetime: deadline
|
31
|
+
# limit_days: limit days
|
32
|
+
# cname: CN
|
24
33
|
def self.certificate_distribution_list_limit_days_for(days:)
|
25
34
|
raise "do not set days param" if days.nil?
|
26
|
-
|
35
|
+
filtering_limit_days_for(list: certificate_distribution_list.uniq, days: days)
|
27
36
|
end
|
28
37
|
|
29
38
|
# Check Provisioning Profiles in the Directory that is ~/Library/MobileDevice/Provisioning Profiles/
|
39
|
+
# @param days: limit days
|
40
|
+
# @return:
|
41
|
+
# expire_datetime: deadline
|
42
|
+
# limit_days: limit days
|
43
|
+
# app_identifier: Bundle Identifier
|
44
|
+
# app_id_name => App ID Name
|
30
45
|
def self.provisioning_profile_list_limit_days_for(days:)
|
31
46
|
raise "do not set days param" if days.nil?
|
32
|
-
|
47
|
+
filtering_limit_days_for(list: provisioning_profile_list.uniq, days: days)
|
33
48
|
end
|
34
49
|
|
50
|
+
# All iPhone Developer and Apple Development List
|
35
51
|
def self.certificate_development_list
|
36
52
|
list = []
|
37
53
|
iphone_list = certificate_list_for(name: "iPhone Developer")
|
38
54
|
apple_list = certificate_list_for(name: "Apple Development")
|
39
|
-
list.concat(iphone_list)
|
40
|
-
list.concat(apple_list)
|
41
|
-
return list
|
55
|
+
list.concat(iphone_list) unless iphone_list.nil?
|
56
|
+
list.concat(apple_list) unless apple_list.nil?
|
57
|
+
return list
|
42
58
|
end
|
43
59
|
|
60
|
+
# All iPhone Distribution and Apple Distribution List
|
44
61
|
def self.certificate_distribution_list
|
45
62
|
list = []
|
46
63
|
iphone_list = certificate_list_for(name: "iPhone Distribution")
|
47
64
|
apple_list = certificate_list_for(name: "Apple Distribution")
|
48
|
-
list.concat(iphone_list)
|
49
|
-
list.concat(apple_list)
|
50
|
-
return list
|
65
|
+
list.concat(iphone_list) unless iphone_list.nil?
|
66
|
+
list.concat(apple_list) unless apple_list.nil?
|
67
|
+
return list
|
51
68
|
end
|
52
69
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
temp_pem_file = Tempfile.new(::File.basename("temp_pem"))
|
57
|
-
|
58
|
-
begin
|
59
|
-
`security find-certificate -a -c "#{name}" -p > #{temp_pem_file.path}`
|
60
|
-
result = `openssl x509 -text -fingerprint -noout -in #{temp_pem_file.path}`
|
61
|
-
|
62
|
-
expire_datetime_match = result.match(/.*Not After :(.*)/)
|
63
|
-
raise "not exits expire date" if expire_datetime_match.nil?
|
64
|
-
|
65
|
-
expire_datetime = Time.parse(expire_datetime_match[1])
|
66
|
-
|
67
|
-
cname_match = result.match(/Subject: .* CN=(.*), OU=.*/)
|
68
|
-
raise "not exists cname:#{result}" if cname_match.nil?
|
69
|
-
cname = cname_match[1]
|
70
|
-
|
71
|
-
limit_days = calc_limit_days(datetime: expire_datetime)
|
72
|
-
|
73
|
-
rescue StandardError => e
|
74
|
-
raise(e.message)
|
75
|
-
ensure
|
76
|
-
temp_pem_file.close && temp_pem_file.unlink
|
77
|
-
end
|
78
|
-
|
79
|
-
return {
|
80
|
-
:expire_datetime => expire_datetime,
|
81
|
-
:limit_days => limit_days,
|
82
|
-
:cname => cname
|
83
|
-
}
|
84
|
-
end
|
85
|
-
|
86
|
-
def self.provisioning_profile_list_info(dir: "~/Library/MobileDevice/Provisioning\\ Profiles/*.mobileprovision")
|
87
|
-
info = []
|
70
|
+
# Provisioning Profile List
|
71
|
+
def self.provisioning_profile_list(dir: "~/Library/MobileDevice/Provisioning\\ Profiles/*.mobileprovision")
|
72
|
+
list = []
|
88
73
|
Dir.glob("#{File.expand_path(dir)}") do |file|
|
89
74
|
file_name_match = file.match(/.*\/(.*)\.mobileprovision/)
|
90
75
|
raise "not exists Provisioning Profile" if file_name_match.nil?
|
@@ -110,47 +95,88 @@ module AppleCertsInfo
|
|
110
95
|
temp_plist_file.close && temp_plist_file.unlink
|
111
96
|
end
|
112
97
|
|
113
|
-
|
98
|
+
list << {
|
114
99
|
:expire_datetime => expire_datetime,
|
115
100
|
:limit_days => limit_days,
|
116
101
|
:app_identifier => app_identifier,
|
117
|
-
:app_id_name => app_id_name
|
102
|
+
:app_id_name => app_id_name,
|
103
|
+
:file_path => file_name_match[0]
|
118
104
|
}
|
119
105
|
end
|
120
|
-
return
|
106
|
+
return list
|
121
107
|
end
|
122
108
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
when "provisioning_profile" then
|
131
|
-
list = provisioning_profile_list_info
|
132
|
-
end
|
133
|
-
puts(list) if @debug_log == true
|
109
|
+
# Certificate Information for target name
|
110
|
+
# @return
|
111
|
+
# expire_datetime: deadline
|
112
|
+
# limit_days: limit days
|
113
|
+
# cname: CN
|
114
|
+
def self.certificate_info_for(name:)
|
115
|
+
raise "do not set name param" if name.nil?
|
134
116
|
|
135
|
-
|
136
|
-
|
137
|
-
|
117
|
+
info = []
|
118
|
+
begin
|
119
|
+
temp_pem_file = certificate_exchange_pem_file_for(name: name)
|
120
|
+
result = `openssl crl2pkcs7 -nocrl -certfile #{temp_pem_file.path} | openssl pkcs7 -print_certs -text -noout`
|
121
|
+
|
122
|
+
expire_datetime_match = result.scan(/.*Not After :(.*)/)
|
123
|
+
raise "not exits expire date" if expire_datetime_match.nil?
|
124
|
+
|
125
|
+
cname_match = result.match(/Subject: .* CN=(.*), OU=.*/)
|
126
|
+
raise "not exists cname:#{result}" if cname_match.nil?
|
127
|
+
|
128
|
+
expire_datetime_match.each do |original_datetime|
|
129
|
+
expire_datetime = Time.parse(original_datetime.first)
|
130
|
+
limit_days = calc_limit_days(datetime: expire_datetime)
|
131
|
+
cname = cname_match[1] # cname is same
|
132
|
+
|
133
|
+
info << {
|
134
|
+
:expire_datetime => expire_datetime,
|
135
|
+
:limit_days => limit_days,
|
136
|
+
:cname => cname,
|
137
|
+
}
|
138
|
+
end
|
139
|
+
rescue StandardError => e
|
140
|
+
raise(e.message)
|
141
|
+
ensure
|
142
|
+
temp_pem_file.close && temp_pem_file.unlink
|
138
143
|
end
|
139
144
|
|
140
|
-
|
145
|
+
return info
|
141
146
|
end
|
142
147
|
|
148
|
+
|
149
|
+
private
|
143
150
|
def self.certificate_list_for(name:)
|
144
|
-
result = `security find-certificate -a -c "#{name}"`
|
151
|
+
result = `security find-certificate -a -c "#{name}" -Z`
|
145
152
|
name_match_list = result.scan(/.*alis".*=\"(.*)\".*/)
|
146
153
|
puts(name_match_list) if @debug_log == true
|
147
154
|
|
148
155
|
info = []
|
149
|
-
name_match_list.each do|name_match|
|
156
|
+
name_match_list.uniq.each do|name_match|
|
150
157
|
info << certificate_info_for(name:name_match[0])
|
151
158
|
end
|
152
159
|
|
153
|
-
info
|
160
|
+
info.flatten!
|
161
|
+
end
|
162
|
+
|
163
|
+
# filtering list
|
164
|
+
def self.filtering_limit_days_for(list:, days:)
|
165
|
+
danger_list = []
|
166
|
+
list.each do |info|
|
167
|
+
danger_list << info if info[:limit_days].to_i <= days.to_i
|
168
|
+
end
|
169
|
+
|
170
|
+
danger_list
|
171
|
+
end
|
172
|
+
|
173
|
+
# exchange pem file
|
174
|
+
# @param name: unique name
|
175
|
+
def self.certificate_exchange_pem_file_for(name:)
|
176
|
+
temp_pem_file = Tempfile.new(::File.basename("temp_pem"))
|
177
|
+
`security find-certificate -a -c "#{name}" -p > #{temp_pem_file.path}`
|
178
|
+
|
179
|
+
temp_pem_file
|
154
180
|
end
|
155
181
|
|
156
182
|
def self.calc_limit_days(datetime:)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apple_certs_info
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- tarappo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -53,7 +53,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
53
53
|
requirements:
|
54
54
|
- - ">="
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
version: 2.
|
56
|
+
version: 2.5.0
|
57
57
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|