@@ -88,29 +88,26 @@ internal final class IdeviceGateway {
8888 guard let plist = plist else {
8989 throw IdeviceGatewayError . invalidPairingFile ( reason: " The file could not be parsed as a property list (plist). " )
9090 }
91+
92+ let requiredRPKeys = [ " private_key " , " public_key " , " identifier " ]
93+ let missingRPKeys = requiredRPKeys. filter { plist [ $0] == nil }
94+ if missingRPKeys. isEmpty {
95+ return . rppairing
96+ }
97+
9198 let requiredLockdownKeys = [
9299 " WiFiMACAddress " , " SystemBUID " , " RootPrivateKey " , " HostPrivateKey " ,
93100 " HostID " , " RootCertificate " , " UDID " , " EscrowBag " , " HostCertificate " ,
94101 " DeviceCertificate "
95102 ]
96103 let missingLockdownKeys = requiredLockdownKeys. filter { plist [ $0] == nil }
97- if !missingLockdownKeys. isEmpty {
98- if missingLockdownKeys. count == requiredLockdownKeys. count {
99- throw IdeviceGatewayError . invalidPairingFile ( reason: " The file is not a valid device pairing plist (missing all required attributes). " )
100- } else {
101- throw IdeviceGatewayError . invalidPairingFile ( reason: " The pairing file is incomplete. Missing attributes: \( missingLockdownKeys. joined ( separator: " , " ) ) . " )
102- }
103- }
104- let requiredRPKeys = [ " private_key " , " public_key " , " identifier " ]
105- let presentRPKeys = requiredRPKeys. filter { plist [ $0] != nil }
106- if presentRPKeys. isEmpty {
104+ if missingLockdownKeys. isEmpty {
107105 return . lockdown
108- } else if presentRPKeys. count == requiredRPKeys. count {
109- return . rppairing
110- } else {
111- let missingRPKeys = requiredRPKeys. filter { plist [ $0] == nil }
112- throw IdeviceGatewayError . invalidPairingFile ( reason: " The file is an incomplete Remote Pairing file. Missing attributes: \( missingRPKeys. joined ( separator: " , " ) ) . " )
113106 }
107+
108+ throw IdeviceGatewayError . invalidPairingFile (
109+ reason: " The pairing file is incomplete. Missing Remote Pairing attributes: \( missingRPKeys. joined ( separator: " , " ) ) ; missing Lockdown attributes: \( missingLockdownKeys. joined ( separator: " , " ) ) . "
110+ )
114111 }
115112 private( set) var pairingFileData : Data ? = nil {
116113 didSet {
0 commit comments