From 00c76f707f511a2c43aee73a9e7f53743f763849 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Mon, 25 Mar 2019 19:24:35 +0100 Subject: [PATCH] Throw specific error if unable to decrypt Normally a bad passphrase. --- TunnelKit/Sources/Core/ConfigurationParser.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/TunnelKit/Sources/Core/ConfigurationParser.swift b/TunnelKit/Sources/Core/ConfigurationParser.swift index 27f4fca..7af7ca0 100644 --- a/TunnelKit/Sources/Core/ConfigurationParser.swift +++ b/TunnelKit/Sources/Core/ConfigurationParser.swift @@ -43,6 +43,9 @@ public class ConfigurationParser { /// Passphrase required to decrypt private keys. case encryptionPassphrase + + /// Encryption passphrase is incorrect or key is corrupt. + case unableToDecrypt(error: Error) } /// Result of the parser. @@ -224,7 +227,7 @@ public class ConfigurationParser { do { clientKey = try container.decrypted(with: passphrase) } catch let e { - unsupportedError = ParsingError.unsupportedConfiguration(option: e.localizedDescription) + unsupportedError = ParsingError.unableToDecrypt(error: e) } } else { clientKey = container