-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCreateNewPushCertificates.rb
executable file
·64 lines (43 loc) · 1.66 KB
/
CreateNewPushCertificates.rb
1
2
3
4
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env ruby
$LOAD_PATH << '.'
require 'spaceship'
require 'openssl'
require 'config'
if ARGV[0].nil?
puts 'Please provide bundle id'
exit
end
app_id = ARGV[0]
client = Spaceship.login(AppMakerConfig::DEV_USER, AppMakerConfig::DEV_PASSWORD)
puts "Logged in"
#Spaceship.select_team
client.team_id = 'P2WQ65BAA8'
app = Spaceship.app.find(app_id)
if app.nil?
puts 'Application not found'
exit
end
puts 'Application found:'
puts app.app_id
puts app.name
puts app.bundle_id
FileUtils::mkdir_p app.name
appNameJoined = app.name.split(' ').join
# Create a new certificate signing request
prod_csr, prod_pkey = Spaceship.certificate.create_certificate_signing_request
# Use the signing request to create a new push certificate
prodCert = Spaceship.certificate.production_push.create!(csr: prod_csr, bundle_id: app_id)
prod_pfx = OpenSSL::PKCS12.create('Abcd1234', app_id, prod_pkey, prodCert.download)
File.open(app.name + '/' + appNameJoined + '_Production_Push.p12', 'w') {
|f| f.write(prod_pfx.to_der)
}
puts 'Production push certificate stored to ' + app.name + '/' + appNameJoined + '_Production_Push.p12'
# Create a new certificate signing request
dev_csr, dev_pkey = Spaceship.certificate.create_certificate_signing_request
# Use the signing request to create a new push certificate
devCert = Spaceship.certificate.development_push.create!(csr: dev_csr, bundle_id: app_id)
dev_pfx = OpenSSL::PKCS12.create('Abcd1234', app_id, dev_pkey, devCert.download)
File.open(app.name + '/' + appNameJoined + '_Development_Push.p12', 'w') {
|f| f.write(dev_pfx.to_der)
}
puts 'Development push certificate stored to ' + app.name + '/' + appNameJoined + '_Development_Push.p12'