I got error NSURLConnection finished with error - code -1100 when executing app in Xcode simulator, and I just see a black window, but there's no any more information I can use to solve the error.
What should I do?
Thank you!
Post
Replies
Boosts
Views
Activity
Hi everyone,
I am trying to authenticate an user through ASWebAuthenticationSession, and after that redirect to an URL that uses the callback scheme.
The authentication page URL is correctly loaded on a browser thanks to ASWebAuthenticationPresentationContextProviding.
But after form completed and authentication successfully, what I am doing is a redirect directly from my server to "http://localhost:5000/ios/hola?hola=hola"
I am trying to catch this URL using a callbackScheme in my iOS app, using the same url that the one which I redirected the browser to, but this is not working.
I also tried to create a Scheme URL to my identifier, and pass it to the callbackScheme, but this is not working either. Documentation is not very clear at how to manage the authentication callback and as a beginner I don't know the way to solve this.
Some help would be appreciated. Thank you for your time!
PD: This is the code of my class
@available(iOS 12.0, *)
class AuthView: UIViewController {
var authSession: ASWebAuthenticationSession!
override func viewDidLoad() {
super.viewDidLoad()
if #available(iOS 13.0, *) {
configureAuthSession()
}
}
	 @available(iOS 13.0, *)
private func configureAuthSession() {
let urlString = "http://localhost:3000/"
guard let url = URL(string: urlString) else { return }
let callbackScheme = "http://localhost:5000/ios/matriga/hola"
authSession = ASWebAuthenticationSession(url: url, callbackURLScheme: callbackScheme)
{ (callbackURL, error) in
guard error == nil, let successURL = callbackURL else { return }
let code = NSURLComponents(string: (successURL.absoluteString))?.queryItems?.filter({ $0.name == "code" }).first
}
authSession.presentationContextProvider = self
authSession.start()
}
}
@available(iOS 12.0, *)
extension AuthView: ASWebAuthenticationPresentationContextProviding {
@available(iOS 12.0, *)
func presentationAnchor(for session: ASWebAuthenticationSession) -> ASPresentationAnchor {
return self.view.window ?? ASPresentationAnchor()
}
}
Hey everyone.
I would like to make an authentication challenge to the browser (Safari) to allow users log in my application.
What I am doing actually in my API is to save a cookie in the browser to persist session. Is it possible to request the cookie from my app?
Thank you in advance
Hey everyone,
Is it possible to make a request to Safari (opening an URL), and after authentication, catch a cookie value taking it back to the program also closing the browser?.
Thanks in advance.
Hello everyone,
I am trying to save an identity into a group keychain. I am doing it this way, following the documentation:
let queryAdd: [String: AnyObject] = [
kSecClass as String: kSecClassGenericPassword,
kSecAttrAccount as String: kSecImportItemIdentity as AnyObject,
kSecValueData as String: identity as SecIdentity,
kSecAttrAccessible as String: kSecAttrAccessibleWhenUnlocked,
kSecAttrAccessGroup as String: accessGroup as AnyObject
]
let resultCode = SecItemAdd(queryAdd as CFDictionary, nil)
if resultCode != noErr {
print("Error saving to Keychain: \(resultCode)")
}
I am getting error (or resultCode) -50, which means password has not been save successfully.
As a no-team programmer, my accessGroup it's just the group Bundle identifier, registered in Signing & Capabilities -> Keychain Sharing. I don't know if maybe the reason of this code is because the group is not alright or something else it's happening, although it looks I am using the identity the right way.
Hey everyone,
I am trying to successfully authenticate in a a system using a certificate stored in the phone (Xcode simulator in this case). I am using Alamofire to do this. Actually, following their documentation, I set the trust certificates of the server url to the session
let manager = ServerTrustManager(evaluators: [location: PinnedCertificatesTrustEvaluator()])
let session = Session(serverTrustManager: manager)
I have seen that probably the best way is to authenticate using the URLCredentials, but I am not able to obtain this from the certificates of the system.
Trying to use my own certificate, I've done something like this:
let filePath = Bundle.main.path(forResource: "alvaro", ofType: "p12")!
let data = try! Data(contentsOf: URL(fileURLWithPath: filePath))
let certificate = SecCertificateCreateWithData(nil, data as CFData)!
As you can see I find .p12 extension certificate directly from the resources (although I am getting Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value), but my final objetive it's to get my app showing that a client certificate is required, allowing this to use the certificate installed on his device when connecting to the website.
Thanks in advance.