Skip to content

armgit / xtool

Public Imported from GitHub
0

Cross-platform Xcode replacement. Build and deploy iOS apps with SwiftPM on Linux, Windows, macOS.

Tie cert to host computer instead of device

kabiroberaid69da9520d59
diff --git a/Supersign/DeveloperServices/Certificates/DeveloperServicesFetchCertificateOperation.swift b/Supersign/DeveloperServices/Certificates/DeveloperServicesFetchCertificateOperation.swift
index d0e67c3..011db35 100644
--- a/Supersign/DeveloperServices/Certificates/DeveloperServicesFetchCertificateOperation.swift
+++ b/Supersign/DeveloperServices/Certificates/DeveloperServicesFetchCertificateOperation.swift
@@ -45,8 +45,8 @@ public struct DeveloperServicesFetchCertificateOperation: DeveloperServicesOpera
platform: context.platform,
teamID: context.teamID,
csr: csr,
- machineName: context.deviceName,
- machineID: context.udid
+ machineName: "Supercharge: \(context.deviceName)",
+ machineID: context.client.deviceInfo.deviceID
)
context.client.send(request) { result in
guard let partialCert = result.get(withErrorHandler: completion) else { return }
@@ -75,11 +75,15 @@ public struct DeveloperServicesFetchCertificateOperation: DeveloperServicesOpera
}
private func revokeCreateSaveCertificate(
- certificate: DeveloperServicesCertificate,
+ certificates: [DeveloperServicesCertificate],
completion: @escaping (Result<SigningInfo, Swift.Error>) -> Void
) {
- let request = DeveloperServicesRevokeCertificateRequest(teamID: context.teamID, certificateID: certificate.id)
- context.client.send(request) { result in
+ let grouper = RequestGrouper<EmptyResponse, Swift.Error>()
+ certificates.forEach {
+ let request = DeveloperServicesRevokeCertificateRequest(teamID: context.teamID, certificateID: $0.id)
+ grouper.add { context.client.send(request, completion: $0) }
+ }
+ grouper.onComplete { result in
guard result.get(withErrorHandler: completion) != nil else { return }
self.createAndSaveCertificate(completion: completion)
}
@@ -92,8 +96,11 @@ public struct DeveloperServicesFetchCertificateOperation: DeveloperServicesOpera
context.client.send(request) { result in
guard let certificates = result.get(withErrorHandler: completion) else { return }
- guard let certificate = certificates.first(where: { $0.attributes.machineID == self.context.udid }) else {
- return self.createAndSaveCertificate(completion: completion)
+ guard let certificate = certificates.first(where: {
+ $0.attributes.machineID == self.context.client.deviceInfo.deviceID
+ }) else {
+ // we need to revoke existing certs, otherwise it doesn't always let us make a new one
+ return self.revokeCreateSaveCertificate(certificates: certificates, completion: completion)
}
guard let signingInfo = self.context.signingInfoManager[self.context.teamID],
@@ -101,7 +108,7 @@ public struct DeveloperServicesFetchCertificateOperation: DeveloperServicesOpera
certificate.attributes.serialNumber.rawValue == serialNumber,
certificate.attributes.expiry > Date()
else { return self.revokeCreateSaveCertificate(
- certificate: certificate, completion: completion
+ certificates: [certificate], completion: completion
) }
completion(.success(signingInfo))