|
@@ -297,7 +297,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
|
|
NCCommunicationCommon.shared.writeLog("initialize Main")
|
|
NCCommunicationCommon.shared.writeLog("initialize Main")
|
|
|
|
|
|
// Clear error certificate
|
|
// Clear error certificate
|
|
- CCUtility.clearCertificateError(account)
|
|
|
|
|
|
+ NCNetworking.shared.certificatesError.removeAll()
|
|
|
|
|
|
// Registeration push notification
|
|
// Registeration push notification
|
|
NCPushNotification.shared().pushNotification()
|
|
NCPushNotification.shared().pushNotification()
|
|
@@ -543,25 +543,24 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
|
|
}
|
|
}
|
|
|
|
|
|
@objc private func checkErrorNetworking() {
|
|
@objc private func checkErrorNetworking() {
|
|
-
|
|
|
|
|
|
+
|
|
if account == "" { return }
|
|
if account == "" { return }
|
|
-
|
|
|
|
|
|
+ guard let currentHost = URL(string: self.urlBase)?.host else { return }
|
|
|
|
+ guard let pushNotificationServerProxyHost = URL(string: NCBrandOptions.shared.pushNotificationServerProxy)?.host else { return }
|
|
|
|
+
|
|
// check unauthorized server (401/403)
|
|
// check unauthorized server (401/403)
|
|
if CCUtility.getPassword(account)!.count == 0 {
|
|
if CCUtility.getPassword(account)!.count == 0 {
|
|
openLogin(viewController: window?.rootViewController, selector: NCGlobal.shared.introLogin, openLoginWeb: true)
|
|
openLogin(viewController: window?.rootViewController, selector: NCGlobal.shared.introLogin, openLoginWeb: true)
|
|
}
|
|
}
|
|
|
|
|
|
- // check certificate untrusted (-1202)
|
|
|
|
- let currentHost = URL(string: self.urlBase)?.host
|
|
|
|
- let pushNotificationServerProxyHost = URL(string: NCBrandOptions.shared.pushNotificationServerProxy)?.host
|
|
|
|
- if let host = CCUtility.getCertificateError(account), host == currentHost || host == pushNotificationServerProxyHost {
|
|
|
|
|
|
+ // check certificate untrusted (-1202)
|
|
|
|
+ if NCNetworking.shared.certificatesError.contains(currentHost) || NCNetworking.shared.certificatesError.contains(pushNotificationServerProxyHost) {
|
|
|
|
+
|
|
|
|
+ let alertController = UIAlertController(title: NSLocalizedString("_ssl_certificate_changed_", comment: ""), message: NSLocalizedString("_server_is_trusted_", comment: ""), preferredStyle: .alert)
|
|
|
|
|
|
- let title = String.localizedStringWithFormat(NSLocalizedString("_ssl_certificate_changed_", comment: ""), host)
|
|
|
|
- let alertController = UIAlertController(title: title, message: NSLocalizedString("_server_is_trusted_", comment: ""), preferredStyle: .alert)
|
|
|
|
-
|
|
|
|
alertController.addAction(UIAlertAction(title: NSLocalizedString("_yes_", comment: ""), style: .default, handler: { action in
|
|
alertController.addAction(UIAlertAction(title: NSLocalizedString("_yes_", comment: ""), style: .default, handler: { action in
|
|
NCNetworking.shared.writeCertificate(url: self.urlBase)
|
|
NCNetworking.shared.writeCertificate(url: self.urlBase)
|
|
- CCUtility.clearCertificateError(self.account)
|
|
|
|
|
|
+ NCNetworking.shared.certificatesError.removeAll()
|
|
self.startTimerErrorNetworking()
|
|
self.startTimerErrorNetworking()
|
|
}))
|
|
}))
|
|
|
|
|
|
@@ -569,14 +568,27 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
|
|
self.startTimerErrorNetworking()
|
|
self.startTimerErrorNetworking()
|
|
}))
|
|
}))
|
|
|
|
|
|
- alertController.addAction(UIAlertAction(title: NSLocalizedString("_certificate_details_", comment: ""), style: .default, handler: { action in
|
|
|
|
- if let navigationController = UIStoryboard(name: "NCViewCertificateDetails", bundle: nil).instantiateInitialViewController() as? UINavigationController {
|
|
|
|
- let viewController = navigationController.topViewController as! NCViewCertificateDetails
|
|
|
|
- viewController.delegate = self
|
|
|
|
- viewController.host = host
|
|
|
|
- self.window?.rootViewController?.present(navigationController, animated: true)
|
|
|
|
- }
|
|
|
|
- }))
|
|
|
|
|
|
+ if NCNetworking.shared.certificatesError.contains(currentHost) {
|
|
|
|
+ alertController.addAction(UIAlertAction(title: NSLocalizedString("_certificate_details_", comment: ""), style: .default, handler: { action in
|
|
|
|
+ if let navigationController = UIStoryboard(name: "NCViewCertificateDetails", bundle: nil).instantiateInitialViewController() as? UINavigationController {
|
|
|
|
+ let viewController = navigationController.topViewController as! NCViewCertificateDetails
|
|
|
|
+ viewController.delegate = self
|
|
|
|
+ viewController.host = currentHost
|
|
|
|
+ self.window?.rootViewController?.present(navigationController, animated: true)
|
|
|
|
+ }
|
|
|
|
+ }))
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if NCNetworking.shared.certificatesError.contains(pushNotificationServerProxyHost) {
|
|
|
|
+ alertController.addAction(UIAlertAction(title: NSLocalizedString("_certificate_details_", comment: ""), style: .default, handler: { action in
|
|
|
|
+ if let navigationController = UIStoryboard(name: "NCViewCertificateDetails", bundle: nil).instantiateInitialViewController() as? UINavigationController {
|
|
|
|
+ let viewController = navigationController.topViewController as! NCViewCertificateDetails
|
|
|
|
+ viewController.delegate = self
|
|
|
|
+ viewController.host = pushNotificationServerProxyHost
|
|
|
|
+ self.window?.rootViewController?.present(navigationController, animated: true)
|
|
|
|
+ }
|
|
|
|
+ }))
|
|
|
|
+ }
|
|
|
|
|
|
window?.rootViewController?.present(alertController, animated: true, completion: {
|
|
window?.rootViewController?.present(alertController, animated: true, completion: {
|
|
self.timerErrorNetworking?.invalidate()
|
|
self.timerErrorNetworking?.invalidate()
|
|
@@ -616,9 +628,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
|
|
}
|
|
}
|
|
NCManageDatabase.shared.clearDatabase(account: account, removeAccount: true)
|
|
NCManageDatabase.shared.clearDatabase(account: account, removeAccount: true)
|
|
|
|
|
|
|
|
+ NCNetworking.shared.certificatesError.removeAll()
|
|
CCUtility.clearAllKeysEnd(toEnd: account)
|
|
CCUtility.clearAllKeysEnd(toEnd: account)
|
|
CCUtility.clearAllKeysPushNotification(account)
|
|
CCUtility.clearAllKeysPushNotification(account)
|
|
- CCUtility.clearCertificateError(account)
|
|
|
|
CCUtility.setPassword(account, password: nil)
|
|
CCUtility.setPassword(account, password: nil)
|
|
|
|
|
|
if wipe {
|
|
if wipe {
|