35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/agent_smith.rb', line 35
def install
delete_all
Dir.chdir (options[:temp_dir] || Dir.mktmpdir) do
system "mkdir -p #{PROVISIONING_PATH.gsub(" ","\\ ")}"
system "git clone #{options[:repo]} repo &> /dev/null"
certificate = open(APPLE_ROOT_CERTIFICATE_URL).read()
prov_profiles = Dir["repo/**/**.mobileprovision"]
puts "#{prov_profiles.count} provisioning profiles found"
prov_profiles.each do |prov_profile|
prov_profile_content = File.read(prov_profile)
p7 = OpenSSL::PKCS7.new(prov_profile_content)
store = OpenSSL::X509::Store.new
cert = OpenSSL::X509::Certificate.new(certificate)
store.add_cert(cert)
verification = p7.verify([cert], store)
if verification
plist = Plist::parse_xml(p7.data)
uuid = plist["UUID"]
system "cp #{prov_profile} #{PROVISIONING_PATH.gsub(" ","\\ ")}#{uuid}.mobileprovision"
puts "#{File.basename(prov_profile)} installed"
else
puts "#{File.basename(prov_profile)} is not valid"
end
end
end
end
|