diff --git a/passKit/Crypto/PGPAgent.swift b/passKit/Crypto/PGPAgent.swift index d2260a1..64caadd 100644 --- a/passKit/Crypto/PGPAgent.swift +++ b/passKit/Crypto/PGPAgent.swift @@ -86,8 +86,13 @@ public class PGPAgent { guard let pgpInterface = pgpInterface else { throw AppError.Encryption } + var keyID = keyID if !pgpInterface.containsPublicKey(with: keyID) { - throw AppError.PgpPublicKeyNotFound(keyID: keyID) + if pgpInterface.keyID.count == 1 { + keyID = pgpInterface.keyID.first! + } else { + throw AppError.PgpPublicKeyNotFound(keyID: keyID) + } } return try pgpInterface.encrypt(plainData: plainData, keyID: keyID) }