NCLogin.swift 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  1. //
  2. // NCLogin.swift
  3. // Nextcloud
  4. //
  5. // Created by Marino Faggiana on 24/02/21.
  6. // Copyright © 2021 Marino Faggiana. All rights reserved.
  7. //
  8. // Author Marino Faggiana <marino.faggiana@nextcloud.com>
  9. //
  10. // This program is free software: you can redistribute it and/or modify
  11. // it under the terms of the GNU General Public License as published by
  12. // the Free Software Foundation, either version 3 of the License, or
  13. // (at your option) any later version.
  14. //
  15. // This program is distributed in the hope that it will be useful,
  16. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. // GNU General Public License for more details.
  19. //
  20. // You should have received a copy of the GNU General Public License
  21. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. //
  23. import UniformTypeIdentifiers
  24. import UIKit
  25. import NextcloudKit
  26. import SwiftEntryKit
  27. import SwiftUI
  28. class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
  29. @IBOutlet weak var imageBrand: UIImageView!
  30. @IBOutlet weak var imageBrandConstraintY: NSLayoutConstraint!
  31. @IBOutlet weak var baseUrlTextField: UITextField!
  32. @IBOutlet weak var loginAddressDetail: UILabel!
  33. @IBOutlet weak var loginButton: UIButton!
  34. @IBOutlet weak var qrCode: UIButton!
  35. @IBOutlet weak var certificate: UIButton!
  36. @IBOutlet weak var enforceServersButton: UIButton!
  37. @IBOutlet weak var enforceServersDropdownImage: UIImageView!
  38. private let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
  39. private var textColor: UIColor = .white
  40. private var textColorOpponent: UIColor = .black
  41. private var activeTextfieldDiff: CGFloat = 0
  42. private var activeTextField = UITextField()
  43. private var shareAccounts: [NKShareAccounts.DataAccounts]?
  44. var loginFlowV2Token = ""
  45. var loginFlowV2Endpoint = ""
  46. var loginFlowV2Login = ""
  47. /// The URL that will show up on the URL field when this screen appears
  48. var urlBase = ""
  49. // Used for MDM
  50. var configServerUrl: String?
  51. var configUsername: String?
  52. var configPassword: String?
  53. var configAppPassword: String?
  54. private var p12Data: Data?
  55. private var p12Password: String?
  56. // MARK: - View Life Cycle
  57. override func viewDidLoad() {
  58. super.viewDidLoad()
  59. // Text color
  60. if NCBrandColor.shared.customer.isTooLight() {
  61. textColor = .black
  62. textColorOpponent = .white
  63. } else if NCBrandColor.shared.customer.isTooDark() {
  64. textColor = .white
  65. textColorOpponent = .black
  66. } else {
  67. textColor = .white
  68. textColorOpponent = .black
  69. }
  70. // Image Brand
  71. imageBrand.image = UIImage(named: "logo")
  72. // Url
  73. baseUrlTextField.textColor = textColor
  74. baseUrlTextField.tintColor = textColor
  75. baseUrlTextField.layer.cornerRadius = 10
  76. baseUrlTextField.layer.borderWidth = 1
  77. baseUrlTextField.layer.borderColor = textColor.cgColor
  78. baseUrlTextField.leftView = UIView(frame: CGRect(x: 0, y: 0, width: 15, height: baseUrlTextField.frame.height))
  79. baseUrlTextField.leftViewMode = .always
  80. baseUrlTextField.rightView = UIView(frame: CGRect(x: 0, y: 0, width: 35, height: baseUrlTextField.frame.height))
  81. baseUrlTextField.rightViewMode = .always
  82. baseUrlTextField.attributedPlaceholder = NSAttributedString(string: NSLocalizedString("_login_url_", comment: ""), attributes: [NSAttributedString.Key.foregroundColor: textColor.withAlphaComponent(0.5)])
  83. baseUrlTextField.delegate = self
  84. baseUrlTextField.isEnabled = !NCBrandOptions.shared.disable_request_login_url
  85. // Login button
  86. loginAddressDetail.textColor = textColor
  87. loginAddressDetail.text = String.localizedStringWithFormat(NSLocalizedString("_login_address_detail_", comment: ""), NCBrandOptions.shared.brand)
  88. // brand
  89. if NCBrandOptions.shared.disable_request_login_url {
  90. baseUrlTextField.isEnabled = false
  91. baseUrlTextField.isUserInteractionEnabled = false
  92. baseUrlTextField.alpha = 0.5
  93. }
  94. // certificate
  95. certificate.setImage(UIImage(named: "certificate")?.image(color: textColor, size: 100), for: .normal)
  96. certificate.isHidden = true
  97. certificate.isEnabled = false
  98. // navigation
  99. let navBarAppearance = UINavigationBarAppearance()
  100. navBarAppearance.configureWithTransparentBackground()
  101. navBarAppearance.shadowColor = .clear
  102. navBarAppearance.shadowImage = UIImage()
  103. navBarAppearance.titleTextAttributes = [.foregroundColor: textColor]
  104. navBarAppearance.largeTitleTextAttributes = [.foregroundColor: textColor]
  105. self.navigationController?.navigationBar.standardAppearance = navBarAppearance
  106. self.navigationController?.view.backgroundColor = NCBrandColor.shared.customer
  107. self.navigationController?.navigationBar.tintColor = textColor
  108. if !NCManageDatabase.shared.getAllTableAccount().isEmpty {
  109. let navigationItemCancel = UIBarButtonItem(barButtonSystemItem: .stop, target: self, action: #selector(self.actionCancel))
  110. navigationItemCancel.tintColor = textColor
  111. navigationItem.leftBarButtonItem = navigationItemCancel
  112. }
  113. if let dirGroupApps = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: NCBrandOptions.shared.capabilitiesGroupApps) {
  114. // Nextcloud update share accounts
  115. if let error = NCAccount().updateAppsShareAccounts() {
  116. NextcloudKit.shared.nkCommonInstance.writeLog("[ERROR] Create share accounts \(error.localizedDescription)")
  117. }
  118. // Nextcloud get share accounts
  119. if let shareAccounts = NKShareAccounts().getShareAccount(at: dirGroupApps, application: UIApplication.shared) {
  120. var accountTemp = [NKShareAccounts.DataAccounts]()
  121. for shareAccount in shareAccounts {
  122. if NCManageDatabase.shared.getTableAccount(predicate: NSPredicate(format: "urlBase == %@ AND user == %@", shareAccount.url, shareAccount.user)) == nil {
  123. accountTemp.append(shareAccount)
  124. }
  125. }
  126. if !accountTemp.isEmpty {
  127. self.shareAccounts = accountTemp
  128. let image = NCUtility().loadImage(named: "person.badge.plus")
  129. let navigationItem = UIBarButtonItem(image: image, style: .plain, target: self, action: #selector(openShareAccountsViewController))
  130. navigationItem.tintColor = textColor
  131. self.navigationItem.rightBarButtonItem = navigationItem
  132. }
  133. }
  134. }
  135. self.navigationController?.navigationBar.setValue(true, forKey: "hidesShadow")
  136. view.backgroundColor = NCBrandColor.shared.customer
  137. NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow(_:)), name: UIResponder.keyboardWillShowNotification, object: nil)
  138. NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide(_:)), name: UIResponder.keyboardWillHideNotification, object: nil)
  139. handleLoginWithAppConfig()
  140. baseUrlTextField.text = urlBase
  141. enforceServersButton.setTitle(NSLocalizedString("_select_server_", comment: ""), for: .normal)
  142. let enforceServers = NCBrandOptions.shared.enforce_servers
  143. if !enforceServers.isEmpty {
  144. baseUrlTextField.isHidden = true
  145. enforceServersDropdownImage.isHidden = false
  146. enforceServersButton.isHidden = false
  147. let actions = enforceServers.map { server in
  148. UIAction(title: server.name, handler: { [self] _ in
  149. enforceServersButton.setTitle(server.name, for: .normal)
  150. baseUrlTextField.text = server.url
  151. })
  152. }
  153. enforceServersButton.layer.cornerRadius = 10
  154. enforceServersButton.menu = .init(title: NSLocalizedString("_servers_", comment: ""), children: actions)
  155. enforceServersButton.showsMenuAsPrimaryAction = true
  156. enforceServersButton.configuration?.titleTextAttributesTransformer =
  157. UIConfigurationTextAttributesTransformer { incoming in
  158. var outgoing = incoming
  159. outgoing.font = UIFont.systemFont(ofSize: 13)
  160. return outgoing
  161. }
  162. }
  163. }
  164. override func viewDidAppear(_ animated: Bool) {
  165. super.viewDidAppear(animated)
  166. if self.shareAccounts != nil, let image = UIImage(systemName: "person.badge.plus")?.withTintColor(.white, renderingMode: .alwaysOriginal), let backgroundColor = NCBrandColor.shared.customer.lighter(by: 10) {
  167. let title = String(format: NSLocalizedString("_apps_nextcloud_detect_", comment: ""), NCBrandOptions.shared.brand)
  168. let description = String(format: NSLocalizedString("_add_existing_account_", comment: ""), NCBrandOptions.shared.brand)
  169. NCContentPresenter().alertAction(image: image, contentModeImage: .scaleAspectFit, sizeImage: CGSize(width: 45, height: 45), backgroundColor: backgroundColor, textColor: textColor, title: title, description: description, textCancelButton: "_cancel_", textOkButton: "_ok_", attributes: EKAttributes.topFloat) { identifier in
  170. if identifier == "ok" {
  171. self.openShareAccountsViewController()
  172. }
  173. }
  174. }
  175. }
  176. private func handleLoginWithAppConfig() {
  177. let accountCount = NCManageDatabase.shared.getAccounts()?.count ?? 0
  178. // load AppConfig
  179. if (NCBrandOptions.shared.disable_multiaccount == false) || (NCBrandOptions.shared.disable_multiaccount == true && accountCount == 0) {
  180. if let configurationManaged = UserDefaults.standard.dictionary(forKey: "com.apple.configuration.managed"), NCBrandOptions.shared.use_AppConfig {
  181. if let serverUrl = configurationManaged[NCGlobal.shared.configuration_serverUrl] as? String {
  182. self.configServerUrl = serverUrl
  183. }
  184. if let username = configurationManaged[NCGlobal.shared.configuration_username] as? String, !username.isEmpty, username.lowercased() != "username" {
  185. self.configUsername = username
  186. }
  187. if let password = configurationManaged[NCGlobal.shared.configuration_password] as? String, !password.isEmpty, password.lowercased() != "password" {
  188. self.configPassword = password
  189. }
  190. if let apppassword = configurationManaged[NCGlobal.shared.configuration_apppassword] as? String, !apppassword.isEmpty, apppassword.lowercased() != "apppassword" {
  191. self.configAppPassword = apppassword
  192. }
  193. }
  194. }
  195. // AppConfig
  196. if let url = configServerUrl {
  197. if let user = self.configUsername, let password = configAppPassword {
  198. return createAccount(urlBase: url, user: user, password: password)
  199. } else if let user = self.configUsername, let password = configPassword {
  200. return getAppPassword(urlBase: url, user: user, password: password)
  201. } else {
  202. urlBase = url
  203. }
  204. }
  205. }
  206. // MARK: - TextField
  207. func textFieldShouldReturn(_ textField: UITextField) -> Bool {
  208. textField.resignFirstResponder()
  209. actionButtonLogin(self)
  210. return false
  211. }
  212. func textFieldDidBeginEditing(_ textField: UITextField) {
  213. self.activeTextField = textField
  214. }
  215. // MARK: - Keyboard notification
  216. @objc internal func keyboardWillShow(_ notification: Notification?) {
  217. activeTextfieldDiff = 0
  218. if let info = notification?.userInfo, let centerObject = self.activeTextField.superview?.convert(self.activeTextField.center, to: nil) {
  219. let frameEndUserInfoKey = UIResponder.keyboardFrameEndUserInfoKey
  220. if let keyboardFrame = info[frameEndUserInfoKey] as? CGRect {
  221. let diff = keyboardFrame.origin.y - centerObject.y - self.activeTextField.frame.height
  222. if diff < 0 {
  223. activeTextfieldDiff = diff
  224. imageBrandConstraintY.constant += diff
  225. }
  226. }
  227. }
  228. }
  229. @objc func keyboardWillHide(_ notification: Notification) {
  230. imageBrandConstraintY.constant -= activeTextfieldDiff
  231. }
  232. // MARK: - Action
  233. @objc func actionCancel() {
  234. dismiss(animated: true) { }
  235. }
  236. @IBAction func actionButtonLogin(_ sender: Any) {
  237. NCNetworking.shared.p12Data = nil
  238. NCNetworking.shared.p12Password = nil
  239. login()
  240. }
  241. @IBAction func actionQRCode(_ sender: Any) {
  242. let qrCode = NCLoginQRCode(delegate: self)
  243. qrCode.scan()
  244. }
  245. @IBAction func actionCertificate(_ sender: Any) {
  246. }
  247. // MARK: - Share accounts View Controller
  248. @objc func openShareAccountsViewController() {
  249. if let shareAccounts = self.shareAccounts, let vc = UIStoryboard(name: "NCShareAccounts", bundle: nil).instantiateInitialViewController() as? NCShareAccounts {
  250. vc.accounts = shareAccounts
  251. vc.enableTimerProgress = false
  252. vc.dismissDidEnterBackground = false
  253. vc.delegate = self
  254. let screenHeighMax = UIScreen.main.bounds.height - (UIScreen.main.bounds.height / 5)
  255. let numberCell = shareAccounts.count
  256. let height = min(CGFloat(numberCell * Int(vc.heightCell) + 45), screenHeighMax)
  257. let popup = NCPopupViewController(contentController: vc, popupWidth: 300, popupHeight: height + 20)
  258. self.present(popup, animated: true)
  259. }
  260. }
  261. // MARK: - Login
  262. private func login() {
  263. guard var url = baseUrlTextField.text?.trimmingCharacters(in: .whitespacesAndNewlines) else { return }
  264. if url.hasSuffix("/") { url = String(url.dropLast()) }
  265. if url.isEmpty { return }
  266. // Check whether baseUrl contain protocol. If not add https:// by default.
  267. if url.hasPrefix("https") == false && url.hasPrefix("http") == false {
  268. url = "https://" + url
  269. }
  270. self.baseUrlTextField.text = url
  271. isUrlValid(url: url)
  272. }
  273. func isUrlValid(url: String, user: String? = nil) {
  274. loginButton.isEnabled = false
  275. NextcloudKit.shared.getServerStatus(serverUrl: url) { _, serverInfoResult in
  276. switch serverInfoResult {
  277. case .success(let serverInfo):
  278. if let host = URL(string: url)?.host {
  279. NCNetworking.shared.writeCertificate(host: host)
  280. }
  281. NextcloudKit.shared.getLoginFlowV2(serverUrl: url) { token, endpoint, login, _, error in
  282. self.loginButton.isEnabled = true
  283. // Login Flow V2
  284. if error == .success, let token, let endpoint, let login {
  285. let vc = UIHostingController(rootView: NCLoginPoll(loginFlowV2Token: token, loginFlowV2Endpoint: endpoint, loginFlowV2Login: login))
  286. self.present(vc, animated: true)
  287. } else if serverInfo.versionMajor < NCGlobal.shared.nextcloudVersion12 { // No login flow available
  288. let alertController = UIAlertController(title: NSLocalizedString("_error_", comment: ""), message: NSLocalizedString("_webflow_not_available_", comment: ""), preferredStyle: .alert)
  289. alertController.addAction(UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .default, handler: { _ in }))
  290. self.present(alertController, animated: true, completion: { })
  291. }
  292. }
  293. case .failure(let error):
  294. self.loginButton.isEnabled = true
  295. if error.errorCode == NSURLErrorServerCertificateUntrusted {
  296. let alertController = UIAlertController(title: NSLocalizedString("_ssl_certificate_untrusted_", comment: ""), message: NSLocalizedString("_connect_server_anyway_", comment: ""), preferredStyle: .alert)
  297. alertController.addAction(UIAlertAction(title: NSLocalizedString("_yes_", comment: ""), style: .default, handler: { _ in
  298. if let host = URL(string: url)?.host {
  299. NCNetworking.shared.writeCertificate(host: host)
  300. }
  301. }))
  302. alertController.addAction(UIAlertAction(title: NSLocalizedString("_no_", comment: ""), style: .default, handler: { _ in }))
  303. alertController.addAction(UIAlertAction(title: NSLocalizedString("_certificate_details_", comment: ""), style: .default, handler: { _ in
  304. if let navigationController = UIStoryboard(name: "NCViewCertificateDetails", bundle: nil).instantiateInitialViewController() as? UINavigationController,
  305. let viewController = navigationController.topViewController as? NCViewCertificateDetails {
  306. if let host = URL(string: url)?.host {
  307. viewController.host = host
  308. }
  309. self.present(navigationController, animated: true)
  310. }
  311. }))
  312. self.present(alertController, animated: true)
  313. } else {
  314. let alertController = UIAlertController(title: NSLocalizedString("_connection_error_", comment: ""), message: error.errorDescription, preferredStyle: .alert)
  315. alertController.addAction(UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .default, handler: { _ in }))
  316. self.present(alertController, animated: true, completion: { })
  317. }
  318. }
  319. }
  320. }
  321. // MARK: - QRCode
  322. func dismissQRCode(_ value: String?, metadataType: String?) {
  323. guard var value = value else { return }
  324. let protocolLogin = NCBrandOptions.shared.webLoginAutenticationProtocol + "login/"
  325. if value.hasPrefix(protocolLogin) && value.contains("user:") && value.contains("password:") && value.contains("server:") {
  326. value = value.replacingOccurrences(of: protocolLogin, with: "")
  327. let valueArray = value.components(separatedBy: "&")
  328. if valueArray.count == 3 {
  329. let user = valueArray[0].replacingOccurrences(of: "user:", with: "")
  330. let password = valueArray[1].replacingOccurrences(of: "password:", with: "")
  331. let urlBase = valueArray[2].replacingOccurrences(of: "server:", with: "")
  332. let serverUrl = urlBase + "/remote.php/dav"
  333. loginButton.isEnabled = false
  334. NextcloudKit.shared.checkServer(serverUrl: serverUrl) { _, error in
  335. self.loginButton.isEnabled = true
  336. if error == .success {
  337. self.createAccount(urlBase: urlBase, user: user, password: password)
  338. } else {
  339. let alertController = UIAlertController(title: NSLocalizedString("_error_", comment: ""), message: error.errorDescription, preferredStyle: .alert)
  340. alertController.addAction(UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .default, handler: { _ in }))
  341. self.present(alertController, animated: true)
  342. }
  343. }
  344. }
  345. }
  346. }
  347. private func getAppPassword(urlBase: String, user: String, password: String) {
  348. NextcloudKit.shared.getAppPassword(url: urlBase, user: user, password: password) { token, _, error in
  349. if error == .success, let password = token {
  350. self.createAccount(urlBase: urlBase, user: user, password: password)
  351. } else {
  352. NCContentPresenter().showError(error: error)
  353. self.dismiss(animated: true, completion: nil)
  354. }
  355. }
  356. }
  357. private func createAccount(urlBase: String, user: String, password: String) {
  358. let controller = UIApplication.shared.firstWindow?.rootViewController as? NCMainTabBarController
  359. if let host = URL(string: urlBase)?.host {
  360. NCNetworking.shared.writeCertificate(host: host)
  361. }
  362. NCAccount().createAccount(urlBase: urlBase, user: user, password: password, controller: controller) { account, error in
  363. if error == .success {
  364. let window = UIApplication.shared.firstWindow
  365. if let controller = window?.rootViewController as? NCMainTabBarController {
  366. controller.account = account
  367. self.dismiss(animated: true)
  368. } else {
  369. if let controller = UIStoryboard(name: "Main", bundle: nil).instantiateInitialViewController() as? NCMainTabBarController {
  370. controller.account = account
  371. controller.modalPresentationStyle = .fullScreen
  372. controller.view.alpha = 0
  373. window?.rootViewController = controller
  374. window?.makeKeyAndVisible()
  375. if let scene = window?.windowScene {
  376. SceneManager.shared.register(scene: scene, withRootViewController: controller)
  377. }
  378. UIView.animate(withDuration: 0.5) {
  379. controller.view.alpha = 1
  380. }
  381. }
  382. }
  383. } else {
  384. let alertController = UIAlertController(title: NSLocalizedString("_error_", comment: ""), message: error.errorDescription, preferredStyle: .alert)
  385. alertController.addAction(UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .default, handler: { _ in }))
  386. self.present(alertController, animated: true)
  387. }
  388. }
  389. }
  390. }
  391. extension NCLogin: NCShareAccountsDelegate {
  392. func selected(url: String, user: String) {
  393. isUrlValid(url: url, user: user)
  394. }
  395. }
  396. extension NCLogin: ClientCertificateDelegate, UIDocumentPickerDelegate {
  397. func didAskForClientCertificate() {
  398. let alertNoCertFound = UIAlertController(title: NSLocalizedString("_no_client_cert_found_", comment: ""), message: NSLocalizedString("_no_client_cert_found_desc_", comment: ""), preferredStyle: .alert)
  399. alertNoCertFound.addAction(UIAlertAction(title: NSLocalizedString("_cancel_", comment: ""), style: .cancel, handler: nil))
  400. alertNoCertFound.addAction(UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .default, handler: { _ in
  401. let documentProviderMenu = UIDocumentPickerViewController(forOpeningContentTypes: [UTType.pkcs12])
  402. documentProviderMenu.delegate = self
  403. self.present(documentProviderMenu, animated: true, completion: nil)
  404. }))
  405. present(alertNoCertFound, animated: true)
  406. }
  407. func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {
  408. let alertEnterPassword = UIAlertController(title: NSLocalizedString("_client_cert_enter_password_", comment: ""), message: "", preferredStyle: .alert)
  409. alertEnterPassword.addAction(UIAlertAction(title: NSLocalizedString("_cancel_", comment: ""), style: .cancel, handler: nil))
  410. alertEnterPassword.addAction(UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .default, handler: { _ in
  411. // let documentProviderMenu = UIDocumentPickerViewController(forOpeningContentTypes: [UTType.pkcs12])
  412. NCNetworking.shared.p12Data = try? Data(contentsOf: urls[0])
  413. NCNetworking.shared.p12Password = alertEnterPassword.textFields?[0].text
  414. self.login()
  415. }))
  416. alertEnterPassword.addTextField { textField in
  417. textField.isSecureTextEntry = true
  418. }
  419. present(alertEnterPassword, animated: true)
  420. }
  421. func onIncorrectPassword() {
  422. NCNetworking.shared.p12Data = nil
  423. NCNetworking.shared.p12Password = nil
  424. let alertWrongPassword = UIAlertController(title: NSLocalizedString("_client_cert_wrong_password_", comment: ""), message: "", preferredStyle: .alert)
  425. alertWrongPassword.addAction(UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .default))
  426. present(alertWrongPassword, animated: true)
  427. }
  428. }