marinofaggiana 3 gadi atpakaļ
vecāks
revīzija
3dcc6454ba

+ 24 - 8
iOSClient/Login/NCLogin.swift

@@ -248,6 +248,30 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
     
     @IBAction func actionCertificate(_ sender: Any) {
         
+        let pathsDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
+        let fileNameCertificate = pathsDirectory.appendingPathComponent(NCGlobal.shared.certificate).path
+        let directoryCertificate = CCUtility.getDirectoryCerificates()!
+        var host = "cloud.nextcloud.com"
+        if let url = URL(string: NCBrandOptions.shared.loginBaseUrl) {
+            let urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: false)
+            if let hostComponets = urlComponents?.host {
+                host = hostComponets
+            }
+        }
+            
+        if FileManager.default.fileExists(atPath: fileNameCertificate) {
+            
+            let certificateToPath = directoryCertificate + "/" + host + ".der"
+        
+            if NCUtilityFileSystem.shared.moveFile(atPath: fileNameCertificate, toPath: certificateToPath) {
+                print("ok")
+            } else {
+                print("error")
+            }
+            
+        } else {
+            print("error")
+        }
     }
     
     // MARK: - Login
@@ -443,12 +467,4 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
             }
         }
     }
-    
-    // MARK: -
-    
-    func getDocumentsDirectory() -> URL {
-
-        let paths = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)
-        return paths[0]
-    }
 }

+ 2 - 1
iOSClient/NCGlobal.swift

@@ -158,8 +158,9 @@ class NCGlobal: NSObject {
     //
     let fileNameRichWorkspace                       = "Readme.md"
     
-    // Certificate pinning (temp)
+    // Certificate pinning
     //
+    let certificate                                 = "certificate.der"
     let certificateTmp                              = "tmp.der"
     let certificateTmpV2                            = "certificatetmp.der"
     

+ 1 - 0
iOSClient/Supporting Files/en.lproj/Localizable.strings

@@ -173,6 +173,7 @@
 "_privacy_"                 = "Privacy";
 "_source_code_"             = "Get source code";
 "_account_select_"          = "Select the account";
+"_host_insert_"             = "Insert the host name, for example";
 
 /* Background of the file listing view */
 "_use_as_background_"       = "Use it as a background";