react-native-webview icon indicating copy to clipboard operation
react-native-webview copied to clipboard

NSURLErrorDomain - 1202 (Certificate)

Open MayeuldP opened this issue 7 years ago • 35 comments

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 ?

MayeuldP avatar Mar 08 '19 15:03 MayeuldP

There is no reason it would be any different from the original component 🤔

Titozzz avatar Mar 14 '19 08:03 Titozzz

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
  • [x] 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 ... 🧐🤔

MayoudP avatar Mar 22 '19 16:03 MayoudP

in my experience, it only occurs on simulator

React Native Environment Info: System: OS: macOS 10.14.3 CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz Memory: 704.05 MB / 16.00 GB Shell: 3.0.0 - /usr/local/bin/fish Binaries: Node: 8.15.0 - ~/.nvm/versions/node/v8.15.0/bin/node Yarn: 1.13.0 - /usr/local/bin/yarn npm: 6.4.1 - ~/.nvm/versions/node/v8.15.0/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2 Android SDK: API Levels: 21, 22, 23, 24, 25, 26, 27, 28 Build Tools: 23.0.1, 23.0.3, 24.0.1, 25.0.0, 25.0.2, 25.0.3, 26.0.1, 26.0.2, 26.0.3, 27.0.2, 27.0.3, 28.0.2, 28.0.3 System Images: android-28 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom IDEs: Android Studio: 3.3 AI-182.5107.16.33.5314842 Xcode: 10.2/10E125 - /usr/bin/xcodebuild npmPackages: react: 16.8.5 => 16.8.5 react-native: 0.59.2 => 0.59.2 npmGlobalPackages: react-native-cli: 2.0.1 react-native-create-library: 3.1.2

fishkingsin avatar Mar 28 '19 06:03 fishkingsin

This is working on my end. Are you sure the network you are connected to is safe? Please try with another network connection.

Titozzz avatar Mar 28 '19 08:03 Titozzz

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 !

MayoudP avatar Mar 28 '19 10:03 MayoudP

maybe you are using some weird VPN or something :)

Titozzz avatar Mar 28 '19 13:03 Titozzz

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

breadadams avatar Apr 05 '19 14:04 breadadams

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
}

Monte9 avatar Apr 07 '19 04:04 Monte9

Glad to see that I'm finally not the only one ;)

MayoudP avatar Apr 08 '19 09:04 MayoudP

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 🤞

breadadams avatar Apr 09 '19 16:04 breadadams

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.

gorvinsky avatar May 08 '19 04:05 gorvinsky

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.

gorvinsky avatar May 24 '19 00:05 gorvinsky

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

rokebrand avatar Jun 18 '19 11:06 rokebrand

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

sckoh avatar Jul 04 '19 09:07 sckoh

I have the same issue when trying to use my localhost server while developping.

makhoutdlw avatar Jul 16 '19 13:07 makhoutdlw

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 !

MayoudP avatar Jul 17 '19 16:07 MayoudP

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...

Dylan0916 avatar Aug 05 '19 01:08 Dylan0916

Do you have any updates?

SmirnovM91 avatar Sep 06 '19 19:09 SmirnovM91

A solution that may work for some is to follow this documentation: https://github.com/react-native-community/react-native-webview/blob/master/docs/Custom-iOS.md#allowing-custom-cas-certifica-authorities-and-enabling-ssl-pinning. Some of that documentation is outdated so you'll have to play with it but it was able to help me find a working solution. More information can be found in this commit https://github.com/react-native-community/react-native-webview/commit/136fbd84915e20912d21370c254f5206b5661d67

jwbnw avatar Dec 09 '19 19:12 jwbnw

Not working on simulator...try info.plist all the keys need to be added. giving sam error:he certificate for this server is invalid. You might be connecting to a server that is pretending to be “127.0.0.1” which could put your confidential information at risk. Also, tried using uploading and trusting same self signed certificate on simulator doesn't work. Also changes to localhost from '127.0.0.1'. Doesn't work.

dhaliwallalit avatar Mar 23 '20 11:03 dhaliwallalit