Skip to content

Commit

Permalink
#3169 fix ssl client certificate (#3223)
Browse files Browse the repository at this point in the history
* fix: set NCLogin as NCNetworking certificate delegate

Signed-off-by: Patrick Fischer <[email protected]>

* fix: ensure UIAlertControllers are presented on main thread

Signed-off-by: Patrick Fischer <[email protected]>

* fix: cancel authentication challenge instead of default action

Signed-off-by: Patrick Fischer <[email protected]>

---------

Signed-off-by: Patrick Fischer <[email protected]>
  • Loading branch information
zero0cool0 authored Jan 30, 2025
1 parent 1196c6b commit a8fd9c9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 11 additions & 3 deletions iOSClient/Login/NCLogin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
return outgoing
}
}

Check warning on line 194 in iOSClient/Login/NCLogin.swift

View workflow job for this annotation

GitHub Actions / Lint

Trailing Whitespace Violation: Lines should not have trailing whitespace (trailing_whitespace)
NCNetworking.shared.certificateDelegate = self
}

override func viewDidAppear(_ animated: Bool) {
Expand Down Expand Up @@ -493,7 +495,9 @@ extension NCLogin: ClientCertificateDelegate, UIDocumentPickerDelegate {
documentProviderMenu.delegate = self
self.present(documentProviderMenu, animated: true, completion: nil)
}))
present(alertNoCertFound, animated: true)
DispatchQueue.main.async {
self.present(alertNoCertFound, animated: true)
}
}

func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {
Expand All @@ -507,15 +511,19 @@ extension NCLogin: ClientCertificateDelegate, UIDocumentPickerDelegate {
alertEnterPassword.addTextField { textField in
textField.isSecureTextEntry = true
}
present(alertEnterPassword, animated: true)
DispatchQueue.main.async {
self.present(alertEnterPassword, animated: true)
}
}

func onIncorrectPassword() {
NCNetworking.shared.p12Data = nil
NCNetworking.shared.p12Password = nil
let alertWrongPassword = UIAlertController(title: NSLocalizedString("_client_cert_wrong_password_", comment: ""), message: "", preferredStyle: .alert)
alertWrongPassword.addAction(UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .default))
present(alertWrongPassword, animated: true)
DispatchQueue.main.async {
self.present(alertWrongPassword, animated: true)
}
}

func poll(loginFlowV2Token: String, loginFlowV2Endpoint: String, loginFlowV2Login: String) {
Expand Down
2 changes: 1 addition & 1 deletion iOSClient/Networking/NCNetworking.swift
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class NCNetworking: NSObject, NextcloudKitDelegate {
completionHandler(URLSession.AuthChallengeDisposition.useCredential, creds)
} else {
self.certificateDelegate?.didAskForClientCertificate()
completionHandler(URLSession.AuthChallengeDisposition.performDefaultHandling, nil)
completionHandler(URLSession.AuthChallengeDisposition.cancelAuthenticationChallenge, nil)
}
} else {
self.checkTrustedChallenge(session, didReceive: challenge, completionHandler: completionHandler)
Expand Down

0 comments on commit a8fd9c9

Please sign in to comment.