I am creating an ios webview using Ionic 4. I have already built the ios platform and I am testing on xcode with the iphone XR-12 simulator. My application calls an iframe to an ip https test with a self-signed certificate. The problem is that ios does not allow me to access this ip because it is self-signed. I’m calling this server with iframe and also use web service that access it from httpclient ionic. I cant access to server.
I have already tried adding the exception using NSAppTransportSecurity
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>MI IP</key>
<dict>
<key>NSIncludesSubdomains</key>
<false/>
<key>NSExceptionAllowInsecureHTTPSLoads</key>
<false/>
<key>NSExceptionRequiresForwardSecrecy</key>
<true/>
<key>NSExceptionMinimumTLSVersion</key>
<string>TLSv1.2</string>
<key>NSThirdPartyExceptionAllowInsecureHTTPSLoads</key>
<false/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<true/>
<key>NSThirdPartyExceptionMinimumTLSVersion</key>
<string>TLSv1.2</string>
<key>NSRequiresCertificateTransparency</key>
<false/>
</dict>
</dict>
</dict>
But in a forum I read that it doesn’t work with ip and that I need a domain like www.example.com
So I tried to modify the host file but I would have to change all redirects and the css and links do not work correctly so I ruled out this possibility of editing the hosts Also try installing the certificates in the simulator. I was dragging the certificate to the simulator and install it and also activate it in certificate trust settings. But it does not work
Already try adding this code in AppDelegate.m
@implementation NSURLRequest(DataController)
+ (BOOL)allowsAnyHTTPSCertificateForHost:(NSString *)host
{
return YES;
}
Also try adding this code in CDVWKWebViewEngine.m
- (void)webView:(WKWebView *)webView
didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge
*)challenge completionHandler:(void (^)
(NSURLSessionAuthChallengeDisposition
disposition, NSURLCredential *credential))completionHandler {
SecTrustRef serverTrust = challenge.protectionSpace.serverTrust;
completionHandler(NSURLSessionAuthChallengeUseCredential,
[NSURLCredential credentialForTrust:serverTrust]);
}
Also add this in config.xml
<preference name="CordovaWebViewEngine" value="CDVUIWebViewEngine"/>
But nothing works
In the logs from simulator ios
Task <837DAB71-F2D7-46C1-A29A-D1AD6736493F>.<2> load failed with error Error Domain=NSURLErrorDomain Code=-1202 “The certificate for this server is invalid. You might be connecting to a server that is pretending to be “IP WEB SITE” which could put your confidential information at risk.” UserInfo={NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, _kCFStreamErrorDomainKey=3, NSErrorPeerCertificateChainKey=( “” ), NSErrorClientCertificateStateKey=0, NSErrorFailingURLKey=https://IPWEB:4430/domesticas3p/registro, NSErrorFailingURLStringKey=https://WEBIP/domesticas3p/registro, NSUnderlyingError=0x7fa1a8e15650 {Error Domain=kCFErrorDomainCFNetwork Code=-1202 “(null)” UserInfo={_kCFStreamPropertySSLClientCertificateState=0, kCFStreamPropertySSLPeerTrust=, _kCFNetworkCFStreamSSLErrorOriginalValue=-9843, _kCFStreamErrorDomainKey=3, _kCFStreamErrorCodeKey=-9843, kCFStreamPropertySSLPeerCer
And dont show nothing in the place where is the iframe and the sime proble calling to web service
Sorry my english, and thank you your help ![:slight_smile: :slight_smile:]()