Browse Source

changed _ssl_certificate_changed_

marinofaggiana 3 years ago
parent
commit
5265c07f2e

+ 1 - 8
iOSClient/AppDelegate.swift

@@ -564,14 +564,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         // check certificate untrusted (-1202)
         if CCUtility.getCertificateError(account) {
             
-            var title = ""
-            if CCUtility.getCertificateErrorSavedFound(account) {
-                title = NSLocalizedString("_ssl_certificate_changed_", comment: "")
-            } else {
-                title = NSLocalizedString("_ssl_certificate_untrusted_", comment: "")
-            }
-            
-            let alertController = UIAlertController(title: title, message: NSLocalizedString("_connect_server_anyway_", comment: ""), preferredStyle: .alert)
+            let alertController = UIAlertController(title: NSLocalizedString("_ssl_certificate_changed_", comment: ""), message: NSLocalizedString("_connect_server_anyway_", comment: ""), preferredStyle: .alert)
                         
             alertController.addAction(UIAlertAction(title: NSLocalizedString("_yes_", comment: ""), style: .default, handler: { action in
                 NCNetworking.shared.writeCertificate(url: self.urlBase)

+ 1 - 1
iOSClient/Networking/NCNetworking.swift

@@ -279,7 +279,7 @@ import Queuer
                         #if !EXTENSION
                         DispatchQueue.main.async {
                             let appDelegate = UIApplication.shared.delegate as! AppDelegate
-                            CCUtility.setCertificateError(appDelegate.account, certificateSavedFound: certificateSavedFound)
+                            CCUtility.setCertificateError(appDelegate.account)
                         }
                         #endif
                     }

+ 1 - 1
iOSClient/Networking/NCNetworkingE2EE.swift

@@ -327,7 +327,7 @@ import Alamofire
                             
                             } else if errorCode == Int(CFNetworkErrors.cfurlErrorServerCertificateUntrusted.rawValue) {
                             
-                                CCUtility.setCertificateError(metadata.account, certificateSavedFound: true)
+                                CCUtility.setCertificateError(metadata.account)
                                 NCManageDatabase.shared.setMetadataSession(ocId: metadata.ocId, session: nil, sessionError: errorDescription, sessionTaskIdentifier: 0, status: NCGlobal.shared.metadataStatusUploadError)
                                                     
                             } else {

+ 1 - 2
iOSClient/Utility/CCUtility.h

@@ -147,8 +147,7 @@
 + (NSData *)getDatabaseEncryptionKey;
 
 + (BOOL)getCertificateError:(NSString *)account;
-+ (BOOL)getCertificateErrorSavedFound:(NSString *)account;
-+ (void)setCertificateError:(NSString *)account certificateSavedFound:(BOOL)certificateSavedFound;
++ (void)setCertificateError:(NSString *)account;
 + (void)clearCertificateError:(NSString *)account;
 
 + (BOOL)getDisableLocalCacheAfterUpload;

+ 8 - 24
iOSClient/Utility/CCUtility.m

@@ -562,31 +562,17 @@
     return true;
 }
 
-+ (BOOL)getCertificateErrorSavedFound:(NSString *)account
-{
-    NSString *key = [@"certificateErrorSavedFound" stringByAppendingString:account];
-    NSString *error = [UICKeyChainStore stringForKey:key service:NCGlobal.shared.serviceShareKeyChain];
-    
-    if (error == nil) {
-        return false;
-    }
-    
-    return true;
-}
-
-+ (void)setCertificateError:(NSString *)account certificateSavedFound:(BOOL)certificateSavedFound
++ (void)setCertificateError:(NSString *)account
 {
     // In background do not write the error
 #if !defined(EXTENSION)
     UIApplicationState state = [[UIApplication sharedApplication] applicationState];
-    if (state == UIApplicationStateBackground || state == UIApplicationStateInactive) { return; }
+    if (state == UIApplicationStateBackground || state == UIApplicationStateInactive) {
+        return;
+    }
+    NSString *key = [@"certificateError" stringByAppendingString:account];
     
-    NSString *keyCertificateError = [@"certificateError" stringByAppendingString:account];
-    NSString *keyCertificateErrorSavedFound = [@"certificateErrorSavedFound" stringByAppendingString:account];
-
-    [UICKeyChainStore setString:@"true" forKey:keyCertificateError service:NCGlobal.shared.serviceShareKeyChain];
-    NSString *sCertificateSavedFound = (certificateSavedFound) ? @"true" : @"false";
-    [UICKeyChainStore setString:sCertificateSavedFound forKey:keyCertificateErrorSavedFound service:NCGlobal.shared.serviceShareKeyChain];
+    [UICKeyChainStore setString:@"true" forKey:key service:NCGlobal.shared.serviceShareKeyChain];
 #else
     return;
 #endif
@@ -594,11 +580,9 @@
 
 + (void)clearCertificateError:(NSString *)account
 {
-    NSString *keyCertificateError = [@"certificateError" stringByAppendingString:account];
-    NSString *keyCertificateErrorSavedFound = [@"certificateErrorSavedFound" stringByAppendingString:account];
+    NSString *key = [@"certificateError" stringByAppendingString:account];
     
-    [UICKeyChainStore setString:nil forKey:keyCertificateError service:NCGlobal.shared.serviceShareKeyChain];
-    [UICKeyChainStore setString:nil forKey:keyCertificateErrorSavedFound service:NCGlobal.shared.serviceShareKeyChain];
+    [UICKeyChainStore setString:nil forKey:key service:NCGlobal.shared.serviceShareKeyChain];
 }
 
 + (BOOL)getDisableLocalCacheAfterUpload