'WKWebView using Simulator: Error Code 1200 - An SSL error has occurred and a secure connection to the server cannot be made
In both situations below I'm successfully connected to WiFi. Using Safari and Chrome (I have a VPN on chrome) with my mac I can successfully connect to google, apple.
When I use an actual device to connect to any website using WKWebView everything works fine.
But when I try to connect to any website (including google, apple, and youtube) using WKWebView and the simulator I get this error.
func webView(_ webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!, withError error: Error) {
let code = error._code
print(code) // prints 1200
print(error.localizedDescription)) // An SSL error has occurred and a secure connection to the server cannot be made
}
Why can I successfully connect using a real device but not the simulator? Btw this just started happening today. It never happened before and I didn't change any Xcode settings.
I found an answer that said in the simulator go to Settings > Developer > Allow HTTP Services and to toggle it on. It still doesn't work wether on or off.
I also tried this which works fine on a real device using WKWebView
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
But on the simulator using WKWebView the website still doesn't show and I get the error:
The certificate for this server is invalid. You might be connecting to a server that is pretending to be "www.google.com" which could put your confidential information at risk.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
