react-native-webview: NSURLErrorDomain - 1202 (Certificate)

Good afternoon, just saw this library today, I’m still and originally using Webview from "react-native", then I saw your repo, so I wanted to give it a try. However, I’m stuck with this error when the Webview try to launch ⏬

capture d ecran 2019-03-08 a 16 20 33

It’s weird, 'cos I don’t get this error with the original Component imported from React-Native… I tried to add an NSExceptionDomains field in my Info.plist, but didn’t work… Does anyone have any ideas about how to resolve this, or for example, ignoring certificates restriction when Webview’s loading ?

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 14
  • Comments: 33 (1 by maintainers)

Most upvoted comments

After having added the following to NSAppTransportSecurity in our target’s Info.plist file:

<key>NSAllowsArbitraryLoads</key>
<true/>

And rebuilding the project, it seems to be working on the simulator again 🤞

Did anyone find any solution?

the community version is not working because it set useWebKit to true by default. if u set useWebKit to false on community version. it will be working

but if useWebKit set false will use UIWebView UIWebView is deprecated and will be removed soon

what should I do…

Glad to see that I’m finally not the only one 😉

Sorry, I actually lost the access to my original account (@MayeuldP ), so here I am again (sorry for the delay) :

I tried with the very basic example :

return (
      <WebView
        source={{ uri: "https://facebook.github.io/react-native/" }}
      />
);

It’s actually working well for Android, on Simulator and Real devices (both) However on iOS, I get the same error with the screen that I added in the first post.

Error loading page, Domain : NSURLErrorDomain, Error Code: 1202, 
The certificate for this server is invalid. 
You might be connecting to a server that i pretending to be "facebook.github.io"
which could put your confidential information at risk.

This is the kind of errors that I get in the log of the simulator :

Mar 22 17:02:33  com.apple.CoreSimulator.SimDevice.235866FF-3DC6-4044-9A28-1A29BBDD3E97[39710] (com.apple.StreamingUnzipService): Unknown key for Boolean: EnableTransactions
Mar 22 17:02:33  com.apple.CoreSimulator.SimDevice.235866FF-3DC6-4044-9A28-1A29BBDD3E97[39710] (com.apple.StreamingUnzipService): Unknown key for Boolean: EnablePressuredExit
Mar 22 17:02:33  com.apple.CoreSimulator.SimDevice.235866FF-3DC6-4044-9A28-1A29BBDD3E97[39710] (com.apple.WebKit.Networking): Unknown key for Boolean: EnableTransactions
Mar 22 17:02:33  com.apple.CoreSimulator.SimDevice.235866FF-3DC6-4044-9A28-1A29BBDD3E97[39710] (com.apple.WebKit.Networking): Unknown key for Boolean: EnablePressuredExit
Mar 22 17:02:33  com.apple.CoreSimulator.SimDevice.235866FF-3DC6-4044-9A28-1A29BBDD3E97[39710] (com.apple.WebKit.Storage): Unknown key for Boolean: EnableTransactions
Mar 22 17:02:33  com.apple.CoreSimulator.SimDevice.235866FF-3DC6-4044-9A28-1A29BBDD3E97[39710] (com.apple.WebKit.Storage): Unknown key for Boolean: EnablePressuredExit
Mar 22 17:02:33  com.apple.CoreSimulator.SimDevice.235866FF-3DC6-4044-9A28-1A29BBDD3E97[39710] (com.apple.WebKit.WebContent): Unknown key for Boolean: EnableTransactions
Mar 22 17:02:33  com.apple.CoreSimulator.SimDevice.235866FF-3DC6-4044-9A28-1A29BBDD3E97[39710] (com.apple.WebKit.WebContent): Unknown key for Boolean: EnablePressuredExit
Mar 22 17:02:33  com.apple.CoreSimulator.SimDevice.235866FF-3DC6-4044-9A28-1A29BBDD3E97[39710] (com.apple.backboard.display.archive): Unknown key for Boolean: EnableTransactions
Mar 22 17:02:33  com.apple.CoreSimulator.SimDevice.235866FF-3DC6-4044-9A28-1A29BBDD3E97[39710] (com.apple.backboard.display.archive): Unknown key for Boolean: EnablePressuredExit
Mar 22 17:02:33  com.apple.CoreSimulator.SimDevice.235866FF-3DC6-4044-9A28-1A29BBDD3E97[39710] (com.apple.uifoundation-bundle-helper): Unknown key for Boolean: EnableTransactions
Mar 22 17:02:33  com.apple.CoreSimulator.SimDevice.235866FF-3DC6-4044-9A28-1A29BBDD3E97[39710] (com.apple.uifoundation-bundle-helper): Unknown key for Boolean: EnablePressuredExit

And here is the error that I get in the Chrome Debugger.

Capture d’écran 2019-03-22 à 17 07 00
  • I, of course, checked that the librairies were both correctly linked for iOS and Android
  • React-Native version : 0.55.3
  • Xcode Version : Xcode 10.1
  • Simulator : iOS 12.1
  • I confirm that this problem is not happening with import { WebView } from "react-native";

I have the strange feeling that this problem has something to deal with xCode … 🧐🤔

If anyone else comes across this with error -1202, my problem was my antivirus was issuing invalid certificates to the simulator, open safari and surf to the website, if it has an issue, view certificate, if it says it’s not trusted and you can see the certificate is by your antivirus, turn your antivirus off, hope this helps someone out there image_2019_06_18T10_47_36_947Z The original Webview component works fine, this is only since changing to the community version

I ran into this too. On simulator it gave me that ^^ error, but when I ran it on a iOS device the url loaded fine.

Here’s the full error object:

{
  "domain": "NSURLErrorDomain",
  "target": 2509,
  "canGoBack": false,
  "url": "",
  "code": -1202,
  "loading": false,
  "title": "",
  "canGoForward": false,
  "description": "The certificate for this server is invalid. You might be connecting to a server that is pretending to be “www.kandouapp.com” which could put your confidential information at risk.",
  "didFailProvisionalNavigation": true
}

It appears that it didn’t works on Simulator on another network connection, however it worked on a real device (iOS), weird and quite contraining but ok on the end… You can close the issue !

We’ve just updated to the community webview over that from react-native directly and started to get this issue.

It may only be on the simulator but it’s a huge blocker as in one case we use a webview for some authentication in the 1st step of an app - and can’t get around it without some hackish code inserting credentials to redux 😓

image

the community version is not working because it set useWebKit to true by default. if u set useWebKit to false on community version. it will be working

Did the trick ! Thank you Sir !

the community version is not working because it set useWebKit to true by default. if u set useWebKit to false on community version. it will be working

I’m having similar problem on both the simulator and the device. Below is the error that I get:

Error loading page
Domain: NSURLErrorDomain
Error Code: -1100
Description: The requested URL was not found on this server.

Let me know if you need more info from me to debug this.

So I have fixed my own issue following this guide. What I did wrong in the first place was creating the external folder and put in the web files physically via finder instead of adding them via Xcode.