Post marked as Apple Recommended
Hi All,
We have started seeing crash with iOS 14.5 for ASWebAuthenticationSession's callbackURLScheme. Is anybody seeing the issue? Is this an intentional change in iOS or a bug?
AuthenticationSession] The provided scheme is not valid. A scheme should not include special characters such as ":" or "/".** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'The provided scheme is not valid. A scheme should not include special characters such as ":" or "/".'
Regards,
Nimesh
Post not yet marked as solved
In iOS 11, if `Settings > Safari > AutoFill > Names and Passwords` is set to `True`, then SFSafariViewController prompts `Save This Password?` alert/actionSheet. However, dismissing the `SFSafariViewController`, dismissing the alert before user has a chance to respond to the alert. How shall I take control of the alert and dismiss the SFSafariViewController only when user has responded to an alert?Thank you!Regards,Nimesh
Post not yet marked as solved
Greetings,I'm seeing an issue where URLSession incorrectly returns response from shared URLCache instead of fetching from remote. Here are the steps to reproduce issue,Steps:1. Download Xcode project from URLCacheBug.2. Open and build Xcode project. You will see the CachePolicy is set to `useProtocolCachePolicy` for URLRequest.2. Tap `Send Request 1` button which sends POST query request with parameters (specifically parameter geometry1). You will see response `Count: 5459` on the screen.3. Tap `Send Request 2` button which sends POST query request with parameters(specifically parameter geometry2). You will see response `Count: 5459` on the screen. This is the same response for request 1 and being incorrectly getting from shared URLCache4. Change the cache policy to `reloadIgnoringLocalCacheData` using segmented control.5. Tap `Send Request 1` and you will see response `Count: 5459` on the screen.6. Tap `Send Request 2` and you will see response `Count: 4672` on the screen. You can see the different response as local cache is being ignored.Here is what seems to be happening,1. First request is send and cached.2. While sending second request header `if-none-match = etag of first response` is being set as the URL of the reuest same as first one.3. Server responds with status code `304 - Not Modified`4. URLSession look for response in the URLCache and finish request with status code `200` and response from cache.5. When request cache policy is `reloadIgnoringLocalCacheData`, request is not being sent with header `if-none-match` and server responds with new and correct response.I've logged a Feedback - FB7664947 for this but wanted to know if others are noticing this as well and is there any workaround other than using different cache policy.What is the correct behavior for client and server in this scenario,1. URLRequest should not set `if-none-match` header for second request as clearly the HTTPBody is different than first request/response is in the cache?2. Server should be forgiving of header `if-none-match` and not respond with `304 - Not Modified `?I have another reproducible case where seeing this behavior and the difference between two request is just one HTTP header.Regards,Nimesh
Post not yet marked as solved
Greetings,I'm seeing that authentication challenge is not being issued for client certificate secured URL for second reqeust, if it is being sent within 30 seconds of the first request. Here is the code and steps I'm following,1. Create a data task from a URL session for a client certificate secured URL.2. Resume the data task.3. The authenticateion challenge of type `NSURLAuthenticationMethodClientCertificate` is being issed.4. Perform default handling on the challenge.5. The task will finish with an error.6. Before 30 seconds elapses, preform step 1 and 2 again.7. The steps 3 and 4 gets skiped and finish the data task as per step 5.class ViewController: UIViewController, URLSessionTaskDelegate, URLSessionDataDelegate {
var dataTask: URLSessionDataTask?
var urlSession: URLSession?
override func viewDidLoad() {
super.viewDidLoad()
let sessionConfiguration = URLSessionConfiguration.default
urlSession = Foundation.URLSession(configuration: sessionConfiguration, delegate: self, delegateQueue: OperationQueue.main)
}
@IBAction func buttonAction(_ sender: Any) {
let url = URL(string: “Client Certificate Secured URL“)! // ClientCertificate
//let url = URL(string: “NTLM Secured URL")! // NTLM
dataTask = urlSession?.dataTask(with: url)
dataTask?.resume()
}
func urlSession(_ session: URLSession, task: URLSessionTask, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
guard challenge.previousFailureCount == 0 else {
challenge.sender?.cancel(challenge)
completionHandler(.cancelAuthenticationChallenge, nil)
return
}
if challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust {
if let trust = challenge.protectionSpace.serverTrust{
var trustResult: SecTrustResultType = SecTrustResultType(rawValue: 0)!
SecTrustEvaluate(trust, &trustResult)
if trustResult == .unspecified || trustResult == .proceed {
let credential = URLCredential(trust: trust)
completionHandler(.useCredential, credential)
}
}
}
else if challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodClientCertificate {
print("protectionSpace: \(challenge.protectionSpace)")
completionHandler(.performDefaultHandling, nil)
}
else {
print("protectionSpace: \(challenge.protectionSpace)")
completionHandler(.performDefaultHandling, nil)
}
}
func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, didReceive data: Data) {
let dataString = String(data: data, encoding: .utf8)
print("dataString: \(String(describing: dataString))")
}
}Here are the important things I noticed,1. If the URL is NTLM secured then there is no issue. The authentication challenge is being issued even if requests are being sent within 30 seconds.2. Sending request after 30 seconds the authentication challenge is being issued correctly.3. While debugging I noticed the `URLSessionConfiguration` has an internal property, `_connectionCachePurgeTimeout` which is set to `30`. Is this coming into picture here? I don't see anyother timeout interval set to `30`Is this a bug or am I missing something?Sorry, at this time, I do not have public URLs available for you to test this.Appreciate any help! Thank you!Regards,Nimesh