On ios, in an ionic hybrid application, how to bypass certificate verification (using self-signed certificates)

My ionic / cordova app now gives errors when used with HTTPS backend

`The certificate for this server is invalid` 

I, in my development environment, use self-signed certificates and use the IP address to connect to the server.

I looked at the certificate using openssl s_client and it looks valid. In fact, I can use the same backend with the Android version of this hybrid application.

Is there any plist or other Xcode parameter to accept a self-signed certificate or ignore this test together - similar to setting NSAppTransportSecurity::NSAllowsArbitraryLoads ?

- EDIT

I have <access origin="*"/> in my config.xml file.

thanks a lot

+5
source share
2 answers

You can add this to the end of AppDelegate.m, but only for testing purposes you must remove it before releasing the application, the apple may not approve the application if it contains this code

 @implementation NSURLRequest(DataController) + (BOOL)allowsAnyHTTPSCertificateForHost:(NSString *)host { return YES; } @end 
+2
source

Try adding this to info.plist

 <key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> </dict> 

Here you can also check the workaround !

0
source

Source: https://habr.com/ru/post/1240585/


All Articles