I am making an app that returns book reviews based on isbn. I am trying to load the Goodreads review widget in a web view but I am getting two errors:
CFNetwork SSLHandshake failed (-9824)
and NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9824)
I have tried several other urls and get the same result.
Here is my code where I am calling the url:
override func viewDidLoad() {
super.viewDidLoad()
let url = NSURL (string: "https://www.goodreads.com/api/index#book.show_by_isbn");
let requestObj = NSURLRequest(URL: url!);
webView.loadRequest(requestObj);
}
In the info.plist I have a goodreads.com
dictionary within the Exception Domains dictionary. I included in goodreads.com NSIncludesSubdomains, NSExceptionsAllowsInsecureHTTPLoads, and NSExceptionsMinimumTLSVersion
(set to TLSv1.1)
Is there something obvious that I am going wrong? Is the domain wrong?
EDIT: For anyone reading this later, I think I have solved it. This page (Does App Store reject submission if NSAllowsArbitraryLoads set to YES?) helped immensely.
The App Store will reject your app if you use NSAllowsArbitraryLoads
. However, they will allow NSAllowsArbitraryLoadsInWebContent
Per Apple developer guidelines,
"Set this key’s value to YES to obtain exemption from ATS policies in your app’s web views, without affecting the ATS-mandated security of your NSURLSession connections. To support older versions of iOS and macOS (older than iOS 10), you can employ this key and still manually configure ATS. To do so, set this key’s value to YES and also configure the NSAllowsArbitraryLoads subways. If you add this key to your Info.plist file, then, irrespective of the value of the key, ATS ignores the value of the NSAllowsArbitraryLoads key."