Reputation: 4559
My ionic/cordova app now gives errors when used with HTTPS backend
`The certificate for this server is invalid`
I am in my development environment, use self-signed certificates, and use IP address to connect with the backend.
I examined the certificate using openssl s_client
and it looks valid. As a matter of fact I am able to use the same backend with android version of this hybrid app.
Is there some plist
or other Xcode
setting to accept a self-signed certificate or ignore this test all together - similar to NSAppTransportSecurity::NSAllowsArbitraryLoads
setting?
--EDIT
I have <access origin="*"/>
in my config.xml
file.
Thanks a lot
Upvotes: 6
Views: 4622
Reputation: 1155
Try adding this to info.plist
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
You can also check some workaround here too !
Upvotes: 0
Reputation: 53351
You can add this at the end of AppDelegate.m, but just for testing purposes, you should remove it before releasing the app, apple might not approve the app if it contains that code
@implementation NSURLRequest(DataController)
+ (BOOL)allowsAnyHTTPSCertificateForHost:(NSString *)host
{
return YES;
}
@end
Upvotes: 4