Fix cannot removing PGP keys
This commit is contained in:
parent
e549db0714
commit
b2d93c8a70
4 changed files with 29 additions and 25 deletions
|
|
@ -156,7 +156,7 @@ class GitServerSettingTableViewController: UITableViewController {
|
||||||
|
|
||||||
if Defaults[.gitSSHKeySource] != nil {
|
if Defaults[.gitSSHKeySource] != nil {
|
||||||
let deleteAction = UIAlertAction(title: "Remove Git SSH Keys", style: .destructive) { _ in
|
let deleteAction = UIAlertAction(title: "Remove Git SSH Keys", style: .destructive) { _ in
|
||||||
Utils.removeGitSSHKeys()
|
self.passwordStore.removeGitSSHKeys()
|
||||||
Defaults[.gitSSHKeySource] = nil
|
Defaults[.gitSSHKeySource] = nil
|
||||||
if let sshLabel = self.sshLabel {
|
if let sshLabel = self.sshLabel {
|
||||||
sshLabel.isEnabled = false
|
sshLabel.isEnabled = false
|
||||||
|
|
|
||||||
|
|
@ -343,7 +343,7 @@ class SettingsTableViewController: UITableViewController {
|
||||||
|
|
||||||
if Defaults[.pgpKeySource] != nil {
|
if Defaults[.pgpKeySource] != nil {
|
||||||
let deleteAction = UIAlertAction(title: "Remove PGP Keys", style: .destructive) { _ in
|
let deleteAction = UIAlertAction(title: "Remove PGP Keys", style: .destructive) { _ in
|
||||||
Utils.removePGPKeys()
|
self.passwordStore.removePGPKeys()
|
||||||
self.pgpKeyTableViewCell.detailTextLabel?.text = "Not Set"
|
self.pgpKeyTableViewCell.detailTextLabel?.text = "Not Set"
|
||||||
}
|
}
|
||||||
optionMenu.addAction(deleteAction)
|
optionMenu.addAction(deleteAction)
|
||||||
|
|
|
||||||
|
|
@ -71,28 +71,6 @@ class Utils {
|
||||||
controller.present(alert, animated: true, completion: completion)
|
controller.present(alert, animated: true, completion: completion)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static func removePGPKeys() {
|
|
||||||
removeFileIfExists(atPath: Globals.pgpPublicKeyPath)
|
|
||||||
removeFileIfExists(atPath: Globals.pgpPrivateKeyPath)
|
|
||||||
Defaults.remove(.pgpKeySource)
|
|
||||||
Defaults.remove(.pgpPublicKeyArmor)
|
|
||||||
Defaults.remove(.pgpPrivateKeyArmor)
|
|
||||||
Defaults.remove(.pgpPrivateKeyURL)
|
|
||||||
Defaults.remove(.pgpPublicKeyURL)
|
|
||||||
Utils.removeKeychain(name: ".pgpKeyPassphrase")
|
|
||||||
}
|
|
||||||
|
|
||||||
static func removeGitSSHKeys() {
|
|
||||||
removeFileIfExists(atPath: Globals.gitSSHPublicKeyPath)
|
|
||||||
removeFileIfExists(atPath: Globals.gitSSHPrivateKeyPath)
|
|
||||||
Defaults.remove(.gitSSHPublicKeyArmor)
|
|
||||||
Defaults.remove(.gitSSHPrivateKeyArmor)
|
|
||||||
Defaults.remove(.gitSSHPublicKeyURL)
|
|
||||||
Defaults.remove(.gitSSHPrivateKeyURL)
|
|
||||||
Utils.removeKeychain(name: ".gitSSHPrivateKeyPassphrase")
|
|
||||||
}
|
|
||||||
|
|
||||||
static func getPasswordFromKeychain(name: String) -> String? {
|
static func getPasswordFromKeychain(name: String) -> String? {
|
||||||
let keychain = Keychain(service: "me.mssun.passforios")
|
let keychain = Keychain(service: "me.mssun.passforios")
|
||||||
do {
|
do {
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ class PasswordStore {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let pgp: ObjectivePGP = ObjectivePGP()
|
var pgp: ObjectivePGP = ObjectivePGP()
|
||||||
|
|
||||||
var pgpKeyPassphrase: String? {
|
var pgpKeyPassphrase: String? {
|
||||||
set {
|
set {
|
||||||
|
|
@ -787,4 +787,30 @@ class PasswordStore {
|
||||||
let encryptedData = try pgp.encryptData(plainData, usingPublicKey: publicKey, armored: Defaults[.encryptInArmored])
|
let encryptedData = try pgp.encryptData(plainData, usingPublicKey: publicKey, armored: Defaults[.encryptInArmored])
|
||||||
return encryptedData
|
return encryptedData
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
func removePGPKeys() {
|
||||||
|
Utils.removeFileIfExists(atPath: Globals.pgpPublicKeyPath)
|
||||||
|
Utils.removeFileIfExists(atPath: Globals.pgpPrivateKeyPath)
|
||||||
|
Defaults.remove(.pgpKeySource)
|
||||||
|
Defaults.remove(.pgpPublicKeyArmor)
|
||||||
|
Defaults.remove(.pgpPrivateKeyArmor)
|
||||||
|
Defaults.remove(.pgpPrivateKeyURL)
|
||||||
|
Defaults.remove(.pgpPublicKeyURL)
|
||||||
|
Utils.removeKeychain(name: ".pgpKeyPassphrase")
|
||||||
|
pgp = ObjectivePGP()
|
||||||
|
publicKey = nil
|
||||||
|
privateKey = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func removeGitSSHKeys() {
|
||||||
|
Utils.removeFileIfExists(atPath: Globals.gitSSHPublicKeyPath)
|
||||||
|
Utils.removeFileIfExists(atPath: Globals.gitSSHPrivateKeyPath)
|
||||||
|
Defaults.remove(.gitSSHPublicKeyArmor)
|
||||||
|
Defaults.remove(.gitSSHPrivateKeyArmor)
|
||||||
|
Defaults.remove(.gitSSHPublicKeyURL)
|
||||||
|
Defaults.remove(.gitSSHPrivateKeyURL)
|
||||||
|
Utils.removeKeychain(name: ".gitSSHPrivateKeyPassphrase")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue