apple_certs_info 0.1.5 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CODE_OF_CONDUCT.md +1 -1
- data/Gemfile.lock +3 -3
- data/README.md +4 -4
- data/apple_certs_info.gemspec +2 -2
- data/lib/apple_certs_info.rb +92 -61
- 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: d832e03b2b9b9bc4258931131ac30b37cc98fff25e42566adcecae71b48634c0
|
4
|
+
data.tar.gz: ff2ca0720578dc99224e3740e75b9a4d97dff1e4d4694ade8e347f17dfa0b392
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16c615e264bc2867d2cd579dd6e80093b19677cef36747853c01286dfcf3319969d154fbb2e2a203724b6e9c8bd3582c0e609edf9a0c5231efe74130cbc9b9d6
|
7
|
+
data.tar.gz: a143ac10d7c70e5ebe9f8f957f83c13b204feac3bbec525c1465fc7b25d2b28f43fa5937b94a29221725597a3d86f63b6a77535ba2a1e3ef1237520463022242
|
data/CODE_OF_CONDUCT.md
CHANGED
@@ -55,7 +55,7 @@ further defined and clarified by project maintainers.
|
|
55
55
|
## Enforcement
|
56
56
|
|
57
57
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
-
reported by contacting the project team at
|
58
|
+
reported by contacting the project team at tarappo@gmail.com. All
|
59
59
|
complaints will be reviewed and investigated and will result in a response that
|
60
60
|
is deemed necessary and appropriate to the circumstances. The project team is
|
61
61
|
obligated to maintain confidentiality with regard to the reporter of an incident.
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
apple_certs_info (0.1
|
4
|
+
apple_certs_info (0.2.1)
|
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
@@ -30,17 +30,17 @@ AppleCertsInfo.provisioning_profile_list_limit_days_for(days: 10)
|
|
30
30
|
|
31
31
|
|
32
32
|
```
|
33
|
-
# Development
|
33
|
+
# iPhone Developer / Apple Development
|
34
34
|
AppleCertsInfo.certificate_development_list_limit_days_for(days: 10)
|
35
35
|
|
36
|
-
# Distribution
|
36
|
+
# iPhone / Apple Distribution
|
37
37
|
AppleCertsInfo.certificate_distribution_list_limit_days_for(days: 10)
|
38
38
|
```
|
39
39
|
|
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,8 +3,8 @@ 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 = ["
|
7
|
-
spec.email = ["
|
6
|
+
spec.authors = ["tarappo"]
|
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"
|
data/lib/apple_certs_info.rb
CHANGED
@@ -15,70 +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
|
-
|
38
|
-
|
53
|
+
iphone_list = certificate_list_for(name: "iPhone Developer")
|
54
|
+
apple_list = certificate_list_for(name: "Apple Development")
|
55
|
+
list.concat(iphone_list)
|
56
|
+
list.concat(apple_list)
|
57
|
+
return list
|
39
58
|
end
|
40
59
|
|
60
|
+
# All iPhone Distribution and Apple Distribution List
|
41
61
|
def self.certificate_distribution_list
|
42
62
|
list = []
|
43
|
-
|
44
|
-
|
63
|
+
iphone_list = certificate_list_for(name: "iPhone Distribution")
|
64
|
+
apple_list = certificate_list_for(name: "Apple Distribution")
|
65
|
+
list.concat(iphone_list)
|
66
|
+
list.concat(apple_list)
|
67
|
+
return list
|
45
68
|
end
|
46
69
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
temp_pem_file = Tempfile.new(::File.basename("temp_pem"))
|
51
|
-
|
52
|
-
begin
|
53
|
-
`security find-certificate -a -c "#{name}" -p > #{temp_pem_file.path}`
|
54
|
-
result = `openssl x509 -text -fingerprint -noout -in #{temp_pem_file.path}`
|
55
|
-
|
56
|
-
expire_datetime_match = result.match(/.*Not After :(.*)/)
|
57
|
-
raise "not exits expire date" if expire_datetime_match.nil?
|
58
|
-
|
59
|
-
expire_datetime = Time.parse(expire_datetime_match[1])
|
60
|
-
|
61
|
-
cname_match = result.match(/Subject: .* CN=(.*), OU=.*/)
|
62
|
-
raise "not exists cname:#{result}" if cname_match.nil?
|
63
|
-
cname = cname_match[1]
|
64
|
-
|
65
|
-
limit_days = calc_limit_days(datetime: expire_datetime)
|
66
|
-
|
67
|
-
rescue StandardError => e
|
68
|
-
raise(e.message)
|
69
|
-
ensure
|
70
|
-
temp_pem_file.close && temp_pem_file.unlink
|
71
|
-
end
|
72
|
-
|
73
|
-
return {
|
74
|
-
:expire_datetime => expire_datetime,
|
75
|
-
:limit_days => limit_days,
|
76
|
-
:cname => cname
|
77
|
-
}
|
78
|
-
end
|
79
|
-
|
80
|
-
def self.provisioning_profile_list_info(dir: "~/Library/MobileDevice/Provisioning\\ Profiles/*.mobileprovision")
|
81
|
-
info = []
|
70
|
+
# Provisioning Profile List
|
71
|
+
def self.provisioning_profile_list(dir: "~/Library/MobileDevice/Provisioning\\ Profiles/*.mobileprovision")
|
72
|
+
list = []
|
82
73
|
Dir.glob("#{File.expand_path(dir)}") do |file|
|
83
74
|
file_name_match = file.match(/.*\/(.*)\.mobileprovision/)
|
84
75
|
raise "not exists Provisioning Profile" if file_name_match.nil?
|
@@ -104,47 +95,87 @@ module AppleCertsInfo
|
|
104
95
|
temp_plist_file.close && temp_plist_file.unlink
|
105
96
|
end
|
106
97
|
|
107
|
-
|
98
|
+
list << {
|
108
99
|
:expire_datetime => expire_datetime,
|
109
100
|
:limit_days => limit_days,
|
110
101
|
:app_identifier => app_identifier,
|
111
102
|
:app_id_name => app_id_name
|
112
103
|
}
|
113
104
|
end
|
114
|
-
return
|
105
|
+
return list
|
115
106
|
end
|
116
107
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
when "provisioning_profile" then
|
125
|
-
list = provisioning_profile_list_info
|
126
|
-
end
|
127
|
-
puts(list) if @debug_log == true
|
108
|
+
# Certificate Information for target name
|
109
|
+
# @return
|
110
|
+
# expire_datetime: deadline
|
111
|
+
# limit_days: limit days
|
112
|
+
# cname: CN
|
113
|
+
def self.certificate_info_for(name:)
|
114
|
+
raise "do not set name param" if name.nil?
|
128
115
|
|
129
|
-
|
130
|
-
|
131
|
-
|
116
|
+
info = []
|
117
|
+
begin
|
118
|
+
temp_pem_file = certificate_exchange_pem_file_for(name: name)
|
119
|
+
result = `openssl crl2pkcs7 -nocrl -certfile #{temp_pem_file.path} | openssl pkcs7 -print_certs -text -noout`
|
120
|
+
|
121
|
+
expire_datetime_match = result.scan(/.*Not After :(.*)/)
|
122
|
+
raise "not exits expire date" if expire_datetime_match.nil?
|
123
|
+
|
124
|
+
cname_match = result.match(/Subject: .* CN=(.*), OU=.*/)
|
125
|
+
raise "not exists cname:#{result}" if cname_match.nil?
|
126
|
+
|
127
|
+
expire_datetime_match.each do |original_datetime|
|
128
|
+
expire_datetime = Time.parse(original_datetime.first)
|
129
|
+
limit_days = calc_limit_days(datetime: expire_datetime)
|
130
|
+
cname = cname_match[1]
|
131
|
+
|
132
|
+
info << {
|
133
|
+
:expire_datetime => expire_datetime,
|
134
|
+
:limit_days => limit_days,
|
135
|
+
:cname => cname
|
136
|
+
}
|
137
|
+
end
|
138
|
+
rescue StandardError => e
|
139
|
+
raise(e.message)
|
140
|
+
ensure
|
141
|
+
temp_pem_file.close && temp_pem_file.unlink
|
132
142
|
end
|
133
143
|
|
134
|
-
|
144
|
+
return info
|
135
145
|
end
|
136
146
|
|
147
|
+
|
148
|
+
private
|
137
149
|
def self.certificate_list_for(name:)
|
138
150
|
result = `security find-certificate -a -c "#{name}"`
|
139
151
|
name_match_list = result.scan(/.*alis".*=\"(.*)\".*/)
|
140
152
|
puts(name_match_list) if @debug_log == true
|
141
153
|
|
142
154
|
info = []
|
143
|
-
name_match_list.each do|name_match|
|
155
|
+
name_match_list.uniq.each do|name_match|
|
144
156
|
info << certificate_info_for(name:name_match[0])
|
145
157
|
end
|
146
158
|
|
147
|
-
info
|
159
|
+
info.flatten!
|
160
|
+
end
|
161
|
+
|
162
|
+
# filtering list
|
163
|
+
def self.filtering_limit_days_for(list:, days:)
|
164
|
+
danger_list = []
|
165
|
+
list.each do |info|
|
166
|
+
danger_list << info if info[:limit_days].to_i <= days.to_i
|
167
|
+
end
|
168
|
+
|
169
|
+
danger_list
|
170
|
+
end
|
171
|
+
|
172
|
+
# exchange pem file
|
173
|
+
# @param name: unique name
|
174
|
+
def self.certificate_exchange_pem_file_for(name:)
|
175
|
+
temp_pem_file = Tempfile.new(::File.basename("temp_pem"))
|
176
|
+
`security find-certificate -a -c "#{name}" -p > #{temp_pem_file.path}`
|
177
|
+
|
178
|
+
temp_pem_file
|
148
179
|
end
|
149
180
|
|
150
181
|
def self.calc_limit_days(datetime:)
|
metadata
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apple_certs_info
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
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-18 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
15
|
-
-
|
15
|
+
- tarappo@gmail.com
|
16
16
|
executables: []
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|