motion-provisioning 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 273aab1a938e5d52d30b14c0a2538ec9d4a973ac902e10be63c5969bb238867c
4
- data.tar.gz: 14e1ae35c646f2ef1f2430434f0ca31e8526e852202b52e9bc3a5d76b157dcc9
3
+ metadata.gz: 1c76a060ff83ed382da227fbe52f1dd8f14d8580d586f647f1983bb9f2f8e379
4
+ data.tar.gz: c6d1822c316b30d3c617433e030fd7103972015524c673af37ee9562fa4e6375
5
5
  SHA512:
6
- metadata.gz: ef44dead0d80e6db7d71d8ef8f66d9ec74a75be7526acea5d0e58b0471362092bf1dcef7518facc6dc313773e7a324615417627eb360e49cc03fe2d27a29a05e
7
- data.tar.gz: 2ae333afe71816a440033eea21e48bea2f754233eef2429bd3692822c732ba6f3f3c9943be359313ef81e6c9272035992914fd784d9818c84888ff15b5574e80
6
+ metadata.gz: 503580b9c3fbcb91cf3509988025f36a6dc6d4463b117a7723b64fe589ef37a1d7aa2a2d4c5b15c33ed061de2ac2e49f38a4446386aa28627c7fbc2dddd614e0
7
+ data.tar.gz: 0f8f12fa5f4fa5e208dd35f9de1730af3d3085c0f0045bf8631a2ce42b63d71ab88db1b3fbdd60dcdbeab2b90f59d611f61a8cbfc3edf47937dcc5f9863e1604
@@ -24,14 +24,13 @@ module MotionProvisioning
24
24
  installed_cert = identities.detect { |e| e[:fingerprint] == fingerprint }
25
25
  if installed_cert
26
26
  Utils.log("Info", "Using certificate '#{installed_cert[:name]}'.")
27
- return installed_cert[:name]
27
+ return installed_cert[:fingerprint]
28
28
  else
29
29
  # The certificate is not installed, so we install the cert and the key
30
30
  import_file(private_key_path)
31
31
  import_file(certificate_path)
32
- name = common_name(certificate_path)
33
- Utils.log("Info", "Using certificate '#{name}'.")
34
- return name
32
+ Utils.log("Info", "Using certificate '#{common_name(certificate_path)}'.")
33
+ return sha1_fingerprint(certificate_path)
35
34
  end
36
35
  end
37
36
 
@@ -48,17 +47,17 @@ module MotionProvisioning
48
47
  end
49
48
  end
50
49
 
51
- # There are no certificates in the server so we create a new one
52
50
  if certificates.empty?
51
+ # There are no certificates in the server so we create a new one
53
52
  Utils.log("Warning", "Couldn't find any existing certificates... creating a new one.")
54
53
  if certificate = create_certificate
55
- return common_name(certificate)
54
+ return sha1_fingerprint(certificate)
56
55
  else
57
56
  Utils.log("Error", "Something went wrong when trying to create a new certificate.")
58
57
  abort
59
58
  end
60
- # There are certificates in the server, but none are installed locally. Revoke all and create a new one.
61
59
  elsif installed_certificate.nil?
60
+ # There are certificates in the server, but none are installed locally. Revoke all and create a new one.
62
61
  Utils.log("Error", "None of the available certificates (#{certificates.count}) is installed on the local machine. Revoking...")
63
62
 
64
63
  # For distribution, ask before revoking
@@ -79,13 +78,43 @@ module MotionProvisioning
79
78
  end
80
79
 
81
80
  if certificate = create_certificate
82
- return common_name(certificate)
81
+ return sha1_fingerprint(certificate)
83
82
  else
84
83
  Utils.log("Error", "Something went wrong when trying to create a new certificate...")
85
84
  abort
86
85
  end
87
- # There are certificates on the server, and one of them is installed locally.
86
+ elsif ENV['recreate_certificate'] != nil
87
+ # Force recreate certificate, even though a valid certificate is already installed locally
88
+
89
+ if self.type == :distribution
90
+ answer = Utils.ask("Info", "There are #{certificates.count} distribution certificates in your account.\n" \
91
+ "Before revoking and creating a new one, ask other team members who might have them installed to share them with you.\n" \
92
+ "Do you want to revoke the existing certificates? (Y/n):")
93
+ if answer.yes?
94
+ certificates.each(&:revoke!)
95
+ end
96
+ else
97
+ answer = Utils.ask("Info", "You have #{certificates.count} development certificates in your account.\n" \
98
+ "Do you want to revoke your existing certificates? (Y/n):")
99
+ if answer.yes?
100
+ if MotionProvisioning.free
101
+ certificates.each do |certificate|
102
+ client.revoke_development_certificate(certificate.motionprovisioning_serialNumber)
103
+ end
104
+ else
105
+ certificates.each(&:revoke!)
106
+ end
107
+ end
108
+ end
109
+
110
+ if certificate = create_certificate
111
+ return sha1_fingerprint(certificate)
112
+ else
113
+ Utils.log("Error", "Something went wrong when trying to create a new certificate.")
114
+ abort
115
+ end
88
116
  else
117
+ # There are certificates on the server, and one of them is installed locally.
89
118
  Utils.log("Info", "Found certificate '#{installed_certificate.name}' which is installed in the local machine.")
90
119
 
91
120
  path = store_certificate_raw(installed_certificate.motionprovisioning_certContent || installed_certificate.download_raw)
@@ -97,7 +126,7 @@ module MotionProvisioning
97
126
  # This certificate is installed on the local machine
98
127
  Utils.log("Info", "Using certificate '#{installed_certificate.name}'.")
99
128
 
100
- common_name(path)
129
+ sha1_fingerprint(path)
101
130
  end
102
131
  end
103
132
 
@@ -191,9 +220,9 @@ module MotionProvisioning
191
220
  Utils.log("Info", "Successfully installed certificate.")
192
221
 
193
222
  if self.type == :distribution
194
- Utils.log("Warning", "You have just created a distribution certificate. These certificates must be shared with other team members by sending them the private key (.p12) and certificate (.cer) files in your output folder and install them in the keychain.")
223
+ Utils.log("Warning", "You have just created a distribution certificate. These certificates must be shared with other team members by sending them the private key (.p12) and certificate (.cer) files in your 'provisioning' folder and install them in the keychain.")
195
224
  else
196
- Utils.log("Warning", "You have just created a development certificate. If you want to use this certificate on another machine, transfer the private key (.p12) and certificate (.cer) files in your output folder and install them in the keychain.")
225
+ Utils.log("Warning", "You have just created a development certificate. If you want to use this certificate on another machine, transfer the private key (.p12) and certificate (.cer) files in your 'provisioning' folder and install them in the keychain.")
197
226
  end
198
227
  Utils.ask("Info", "Press any key to continue...")
199
228
 
@@ -1,3 +1,3 @@
1
1
  module MotionProvisioning
2
- VERSION = "1.0.3"
2
+ VERSION = "1.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motion-provisioning
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Villacampa
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-05-04 00:00:00.000000000 Z
12
+ date: 2020-05-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: highline